Skip to content

Commit 978fc09

Browse files
committed
fix(cli): improve error handling in CLI command execution
1 parent 2d6dfdf commit 978fc09

1 file changed

Lines changed: 14 additions & 1 deletion

File tree

‎src/index.ts‎

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
11
import { createCliCommand } from "./cli/build-command.ts";
22

3-
await createCliCommand().parseAsync();
3+
const runCli = async (): Promise<void> => {
4+
try {
5+
await createCliCommand().parseAsync();
6+
} catch (error) {
7+
const message =
8+
error instanceof Error && error.message.length > 0
9+
? `${error.message}\n`
10+
: "Unknown CLI error\n";
11+
process.stderr.write(message);
12+
process.exitCode = 1;
13+
}
14+
};
15+
16+
runCli();

0 commit comments

Comments
 (0)