Skip to content

Commit

Permalink
Print a more friendly error message
Browse files Browse the repository at this point in the history
Follow-up for #116.

Category: fix
Closes: #120
  • Loading branch information
vweevers committed Apr 26, 2024
1 parent 7311b2c commit 2142aec
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ Options:
- `--report <reporter>`: see [Reporters](#reporters)
- `--[no-]color`: force color in report (detected by default)
- `--fix`: backwards-compatible alias for fix command
- `--verbose`: enable verbose output

### Commands

Expand Down
1 change: 1 addition & 0 deletions USAGE
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ Options:
--no-commits Don't populate release with commits
--gte <version> Only include versions greater than or equal to this
--lte <version> Only include versions less than or equal to this
--verbose Enable verbose output

Examples:
# Lint *.md files
Expand Down
11 changes: 9 additions & 2 deletions cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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)
}

Expand Down

0 comments on commit 2142aec

Please sign in to comment.