Bug: Rejected promises are handled incorrectly (process returns zero status code)
- Dominant language
- JavaScript
- Stars
- 5.6k
- Forks
- 278
- PR merge metrics
- No merged PRs in 30d
Description
Hello!
Thank you for this great library!
However, the rejected promises, which are returned from the commands are handled incorrectly.
I've created a simple repository to demonstrate the issue:
https://github.com/slavafomin/vorpal-promise-rejection-issue
Here's the minimal example:
```js
const vorpal = require('vorpal')();
vorpal
.command('test-callback')
.action((args, callback) =>
setTimeout(() =>
callback(new Error('Something bad happened...')), 500
)
)
;
vorpal
.command('test-promise')
.action(args =>
new Promise((resolve, reject) =>
setTimeout(() =>
reject(new Error('Something bad happened...')), 500
)
)
)
;
// vorpal.parse(['', '', 'test-callback']);
vorpal.parse(['', '', 'test-promise']);
```
When callback is used, then error is logged to the console and process exists with non-zero status code. However, when rejected promise is returned, then the `Unhandled promise rejection` warning is generated and process exits with zero code (which is a bug).
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.