Exit code from `depcheck` executable
See original GitHub issueUsing the depcheck
executable should exit with an error code if there are unused dependencies. Running it on my project this doesnt appear to be the case.
$ depcheck
Unused devDependencies
* gulp-eslint
* should-http
Missing dependencies
* mongoose-text-search
Results in an exit code:
$ echo $?
0
Versions: Node: v5.7.0 depcheck: 0.6.3.
I’ve had a look around in the code and the issue appears to stem from this block of code:
https://github.com/depcheck/depcheck/blob/6cb92533adf3ed2ed3f6054d6cb3c51e56731615/bin/depcheck#L11-L13
If you move the process.exit
to outside of the on('finish')
callback then it works as expected. Have you seen this issue before? What was the reasoning behind adding that callback?
Edit: This was introduced here: https://github.com/depcheck/depcheck/commit/44124dd908efb5b638b1d417ece5e2aa7a2daa50
Checking out the version before the 0.6.0 release (0.5.11) has fixed the issue.
Edit 2: I’ve added a regression test for this issue in my fork: https://github.com/domharrington/depcheck/commit/99e6ce1816e9e457a7366b969551472f355991b0 Any help would be appreciated!
Edit 3:
According to the node docs, process.stdout
never emits a finish event: https://nodejs.org/api/process.html#process_process_stdout. Can confirm this is the case as when i put a log statement into that callback, it never gets called.
Issue Analytics
- State:
- Created 7 years ago
- Comments:16 (6 by maintainers)
Top GitHub Comments
I made some tests and it seems that there is only an exit code >0 when there are unused dependencies.
Any chance we get get a new release published to npm with this fix?