Extract CliError into src/errors.ts
CliError used to live in cli.ts and was imported by configFile.ts purely
to grab a one-line class — the dependency arrow said 'config-file loader
depends on the CLI parser' when really it just needed a shared error
type.
Moving CliError to its own errors.ts module flattens the graph:
errors.ts (no internal deps)
|
+-- cli.ts
+-- configFile.ts
+-- config.ts (will use it in the next commit)
cli.ts re-exports CliError for any consumer that prefers to keep
importing it from there; the canonical home is now errors.ts.
This commit is contained in:
+1
-8
@@ -27,14 +27,7 @@ import { fileURLToPath } from "node:url";
|
||||
import { parseArgs } from "node:util";
|
||||
|
||||
import { DEFAULT_CONFIG, defaultConfigPath } from "./config.ts";
|
||||
|
||||
/**
|
||||
* Thrown when CLI input is invalid (unknown option, missing value, bad
|
||||
* number, malformed config file). Distinct from runtime errors so the
|
||||
* entry point can exit with code 2 (user error) instead of code 1
|
||||
* (runtime failure).
|
||||
*/
|
||||
export class CliError extends Error {}
|
||||
import { CliError } from "./errors.ts";
|
||||
|
||||
/**
|
||||
* Result of `parseCliArgs`. Numeric fields are `undefined` when the user
|
||||
|
||||
Reference in New Issue
Block a user