refactor: cleanup error output and do not add red color to help output (#8778)
This commit is contained in:
1 parent
e4fa9ae610
commit
965c3c99db
1 file changed
+18
-14
@@ -35,7 +35,7 @@ function buildLocalCommands(cli, isLocalProject) {
|
|||||||
|
|
||||||
function resolveLocalCommand(command) {
|
function resolveLocalCommand(command) {
|
||||||
if (!isLocalProject) {
|
if (!isLocalProject) {
|
||||||
cli.showHelp()
|
cli.showHelp((s: string) => console.log(s))
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -44,12 +44,8 @@ function buildLocalCommands(cli, isLocalProject) {
|
|||||||
)!
|
)!
|
||||||
return require(cmdPath).default
|
return require(cmdPath).default
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
if (!process.env.NODE_ENV?.startsWith("prod")) {
|
console.error(err)
|
||||||
console.log("--------------- ERROR ---------------------")
|
cli.showHelp((s: string) => console.error(s))
|
||||||
console.log(err)
|
|
||||||
console.log("-------------------------------------------")
|
|
||||||
}
|
|
||||||
cli.showHelp()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -484,15 +480,23 @@ export default (argv) => {
|
|||||||
const arg = argv.slice(2)[0]
|
const arg = argv.slice(2)[0]
|
||||||
const suggestion = arg ? didYouMean(arg, availableCommands) : ``
|
const suggestion = arg ? didYouMean(arg, availableCommands) : ``
|
||||||
|
|
||||||
if (!process.env.NODE_ENV?.startsWith("prod")) {
|
if (msg) {
|
||||||
console.log("--------------- ERROR ---------------------")
|
reporter.error(msg)
|
||||||
console.log(err)
|
console.log()
|
||||||
console.log("-------------------------------------------")
|
}
|
||||||
|
if (suggestion) {
|
||||||
|
reporter.info(suggestion)
|
||||||
|
console.log()
|
||||||
}
|
}
|
||||||
|
|
||||||
cli.showHelp()
|
if (err) {
|
||||||
reporter.info(suggestion)
|
console.error("--------------- ERROR ---------------------")
|
||||||
reporter.info(msg)
|
console.error(err)
|
||||||
|
console.error("-------------------------------------------")
|
||||||
|
}
|
||||||
|
|
||||||
|
cli.showHelp((s: string) => console.error(s))
|
||||||
|
process.exit(1)
|
||||||
})
|
})
|
||||||
.parse(argv.slice(2))
|
.parse(argv.slice(2))
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user