Skip to content

Commit

Permalink
refactor: cleanup error output and do not add red color to help output (
Browse files Browse the repository at this point in the history
  • Loading branch information
thetutlage authored Aug 27, 2024
1 parent e4fa9ae commit 965c3c9
Showing 1 changed file with 18 additions and 14 deletions.
32 changes: 18 additions & 14 deletions packages/cli/medusa-cli/src/create-cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ function buildLocalCommands(cli, isLocalProject) {

function resolveLocalCommand(command) {
if (!isLocalProject) {
cli.showHelp()
cli.showHelp((s: string) => console.log(s))
}

try {
Expand All @@ -44,12 +44,8 @@ function buildLocalCommands(cli, isLocalProject) {
)!
return require(cmdPath).default
} catch (err) {
if (!process.env.NODE_ENV?.startsWith("prod")) {
console.log("--------------- ERROR ---------------------")
console.log(err)
console.log("-------------------------------------------")
}
cli.showHelp()
console.error(err)
cli.showHelp((s: string) => console.error(s))
}
}

Expand Down Expand Up @@ -484,15 +480,23 @@ export default (argv) => {
const arg = argv.slice(2)[0]
const suggestion = arg ? didYouMean(arg, availableCommands) : ``

if (!process.env.NODE_ENV?.startsWith("prod")) {
console.log("--------------- ERROR ---------------------")
console.log(err)
console.log("-------------------------------------------")
if (msg) {
reporter.error(msg)
console.log()
}
if (suggestion) {
reporter.info(suggestion)
console.log()
}

if (err) {
console.error("--------------- ERROR ---------------------")
console.error(err)
console.error("-------------------------------------------")
}

cli.showHelp()
reporter.info(suggestion)
reporter.info(msg)
cli.showHelp((s: string) => console.error(s))
process.exit(1)
})
.parse(argv.slice(2))
}

0 comments on commit 965c3c9

Please sign in to comment.