Skip to content

Commit 0f789d0

Browse files
authored
[Playground CLI] Improve error reporting (#2401)
Improves Playground CLI error reporting in two ways: * Stop printing the stack trace if the `--debug` flag isn't set. The typical errors are similar to "unknown option --blueprin" and displaying the stack trace makes the user experience worse. * Rejects unrecognized options. Before this PR, a typo in one of the flags will go undetected until the user realizes the CLI doesn't do what they want it to. With this PR, the typo is immediately apparent as the process will short-circuit and report a failure. We still support both kebab-cased and camelCased CLI flags ## Testing instructions Confirm this command prints a short error message: ``` node --experimental-strip-types --experimental-transform-types --disable-warning=ExperimentalWarning --import ./packages/meta/src/node-es-module-loader/register.mts ./packages/playground/cli/src/cli.ts server --php=8.4 --blueprin=./file.json ``` Add `--debug` and confirm you can see the entire stacktrace
1 parent ad6583c commit 0f789d0

File tree

2 files changed

+215
-205
lines changed

2 files changed

+215
-205
lines changed

packages/playground/cli/src/cli.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
11
import { parseOptionsAndRunCLI } from './run-cli';
22

33
// Do not await this as top-level await is not supported in all environments.
4-
parseOptionsAndRunCLI().catch((e: any) => {
5-
// eslint-disable-next-line no-console
6-
console.error(e);
7-
process.exit(1);
8-
});
4+
parseOptionsAndRunCLI();

0 commit comments

Comments
 (0)