commitizen / commitizen/cz-cli

Remove stack trace from error when committing without staging files

Open
#473 3 comments 1 reaction 0 assignees View on GitHub
Dominant language
JavaScript
Stars
17.5k
Forks
566
Avg merge
8h 16m
Merged PRs (30d)
1

Description

When you run `git cz` when there are no files staged, the error message includes a stack trace. The stack trace is unnecessary and makes a known error look like an unexpected failure.

instead of this:
````
$ git cz
/usr/local/lib/node_modules/commitizen/dist/cli/strategies/git-cz.js:87
throw new Error('No files added to staging! Did you forget to run git add?');
^

Error: No files added to staging! Did you forget to run git add?
at /usr/local/lib/node_modules/commitizen/dist/cli/strategies/git-cz.js:87:13
at /usr/local/lib/node_modules/commitizen/dist/commitizen/staging.js:25:5
at ChildProcess.exithandler (child_process.js:263:7)
at emitTwo (events.js:125:13)
at ChildProcess.emit (events.js:213:7)
at maybeClose (internal/child_process.js:927:16)
at Socket.stream.socket.on (internal/child_process.js:348:11)
at emitOne (events.js:115:13)
at Socket.emit (events.js:210:7)
at Pipe._handle.close [as _onclose] (net.js:547:12)
````

It should instead look like this:

````
$ git cz
Error: No files added to staging! Did you forget to run git add?
````

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.