Skip to content

Commit 1cf710f

Browse files
committed
Fixes error output
1 parent 26d0483 commit 1cf710f

File tree

2 files changed

+21
-16
lines changed

2 files changed

+21
-16
lines changed

.changeset/clever-pillows-cough.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@codeshift/cli': patch
3+
---
4+
5+
Fixes how the CLI renders errors to users

packages/cli/src/index.ts

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -108,22 +108,22 @@ Examples:
108108

109109
program.exitOverride();
110110

111-
try {
112-
program.parse(process.argv);
113-
} catch (error) {
114-
if (error instanceof CommanderError) {
115-
console.log(error);
111+
(async function() {
112+
try {
113+
await program.parseAsync(process.argv);
114+
} catch (error) {
115+
if (error instanceof CommanderError) {
116+
console.error(chalk.red(error.message));
117+
process.exit(error.exitCode);
118+
}
116119

117-
console.error(chalk.red(error.message));
118-
process.exit(error.exitCode);
119-
}
120+
if (error instanceof InvalidUserInputError) {
121+
console.warn(program.help());
122+
console.warn(chalk.red(error.message));
123+
process.exit(9);
124+
}
120125

121-
if (error instanceof InvalidUserInputError) {
122-
console.warn(program.help());
123-
console.warn(chalk.red(error.message));
124-
process.exit(9);
126+
console.error(chalk.red(error));
127+
process.exit(1);
125128
}
126-
127-
console.error(chalk.red(error));
128-
process.exit(3);
129-
}
129+
})();

0 commit comments

Comments
 (0)