From 2142aec3720d13c15447418902e5250c1af7304d Mon Sep 17 00:00:00 2001 From: Vincent Weevers Date: Fri, 26 Apr 2024 23:28:47 +0200 Subject: [PATCH] Print a more friendly error message Follow-up for #116. Category: fix Closes: #120 --- README.md | 1 + USAGE | 1 + cli.js | 11 +++++++++-- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index b8c35d6..bddfffe 100644 --- a/README.md +++ b/README.md @@ -124,6 +124,7 @@ Options: - `--report `: see [Reporters](#reporters) - `--[no-]color`: force color in report (detected by default) - `--fix`: backwards-compatible alias for fix command +- `--verbose`: enable verbose output ### Commands diff --git a/USAGE b/USAGE index c09b4f1..0bf84f2 100644 --- a/USAGE +++ b/USAGE @@ -27,6 +27,7 @@ Options: --no-commits Don't populate release with commits --gte Only include versions greater than or equal to this --lte Only include versions less than or equal to this + --verbose Enable verbose output Examples: # Lint *.md files diff --git a/cli.js b/cli.js index 083e705..ada9dcc 100644 --- a/cli.js +++ b/cli.js @@ -11,7 +11,7 @@ if (process.version.match(/^v(\d+)\./)[1] < 16) { } const argv = subarg(process.argv.slice(2), { - boolean: ['fix', 'help', 'version', 'commits'], + boolean: ['fix', 'help', 'version', 'commits', 'verbose'], string: ['report'], default: { fix: false, @@ -68,7 +68,14 @@ function files (rest) { } function done (err, result) { - if (err) throw err + if (err) { + // Due to bundling the CLI into 1 file the error can be noisy (#120) so + // print a more friendly (shorter) message by default. + if (argv.verbose) throw err + console.error('%s: %s', err.name, err.message || err) + process.exit(1) + } + process.exit(result.code) }