这是indexloc提供的服务,不要输入任何密码
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions src/commands/new.ts
Original file line number Diff line number Diff line change
Expand Up @@ -682,21 +682,21 @@ module.exports = {
// #endregion

// #region Remove Demo code
if (removeDemo === true) {
startSpinner(" Removing fancy demo code")
try {
const IGNITE = "node " + filesystem.path(__dirname, "..", "..", "bin", "ignite")
const removeDemoPart = removeDemo === true ? "code" : "markup"
startSpinner(` Removing fancy demo ${removeDemoPart}`)
try {
const IGNITE = "node " + filesystem.path(__dirname, "..", "..", "bin", "ignite")
const CMD = removeDemo === true ? "remove-demo" : "remove-demo-markup"

log(`Ignite bin path: ${IGNITE}`)
await system.run(`${IGNITE} remove-demo ${targetPath}`, {
onProgress: log,
})
} catch (e) {
log(e)
p(yellow("Unable to remove demo code."))
}
stopSpinner(" Removing fancy demo code", "🛠️")
log(`Ignite bin path: ${IGNITE}`)
await system.run(`${IGNITE} ${CMD} ${targetPath}`, {
onProgress: log,
})
} catch (e) {
log(e)
p(yellow(`Unable to remove demo ${removeDemoPart}.`))
}
stopSpinner(` Removing fancy demo ${removeDemoPart}`, "🛠️")
// #endregion

// #region Format generator templates EOL for Windows
Expand Down
2 changes: 1 addition & 1 deletion src/commands/remove-demo-markup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ module.exports = {

// Run prettier at the end to clean up any spacing issues
if (!dryRun) {
await system.run(`npx prettier@2.6.2 --write "./app/**/*.{js,jsx,json,md,ts,tsx}"`, {
await system.run(`npx prettier@2.8.1 --write "./app/**/*.{js,jsx,json,md,ts,tsx}"`, {
trim: true,
})
}
Expand Down
18 changes: 13 additions & 5 deletions src/tools/demo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,11 @@ export enum CommentType {

/**
* Regex pattern to find the various types of // @demo remove-x comments
* Also finds # @demo remove-file for maestro files
*
* NOTE: This currently will _NOT_ remove a multiline comment
*/
export const demoMarkupRegex = /\s*\/\/\s*@demo.*|{?\/.*@demo.*\/}?/gm
export const demoMarkupRegex = /(\/\/|#)\s*@demo.*|{?\/.*@demo.*\/}?/gm

/**
* Take the file content as a string and remove any
Expand Down Expand Up @@ -156,7 +157,15 @@ async function update({
const comments: CommentType[] = []

if (await exists(path, REMOVE_FILE)) {
if (!dryRun && !onlyMarkup) filesystem.remove(path)
if (!dryRun) {
if (onlyMarkup) {
const contents = read(path)
const sanitized = demo.sanitize(contents)
filesystem.write(path, sanitized)
} else {
filesystem.remove(path)
}
}
comments.push(REMOVE_FILE)
return { path, comments }
}
Expand All @@ -167,9 +176,8 @@ async function update({
REMOVE_BLOCK_START,
REMOVE_BLOCK_END,
]
const shouldUpdate = onlyMarkup
? RegExp(demoMarkupRegex, "gm")
: RegExp(operations.join("|"), "g")

const shouldUpdate = onlyMarkup ? demoMarkupRegex : RegExp(operations.join("|"), "g")

if (await exists(path, shouldUpdate)) {
const before = read(path)
Expand Down