Skip to content

Commit 2bcfee7

Browse files
committedNov 5, 2018
Add hardRejection option
Fixes #94
1 parent f60c26e commit 2bcfee7

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed
 

‎index.js

+6-3
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@ delete require.cache[__filename];
1515
const parentDir = path.dirname(module.parent.filename);
1616

1717
module.exports = (helpMessage, options) => {
18-
hardRejection();
19-
2018
if (typeof helpMessage === 'object' && !Array.isArray(helpMessage)) {
2119
options = helpMessage;
2220
helpMessage = '';
@@ -33,9 +31,14 @@ module.exports = (helpMessage, options) => {
3331
help: helpMessage,
3432
autoHelp: true,
3533
autoVersion: true,
36-
booleanDefault: false
34+
booleanDefault: false,
35+
hardRejection: true
3736
}, options);
3837

38+
if (options.hardRejection) {
39+
hardRejection();
40+
}
41+
3942
const minimistFlags = options.flags && typeof options.booleanDefault !== 'undefined' ? Object.keys(options.flags).reduce(
4043
(flags, flag) => {
4144
if (flags[flag].type === 'boolean' && !Object.prototype.hasOwnProperty.call(flags[flag], 'default')) {

‎readme.md

+7
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,13 @@ const cli = meow(`
235235
*/
236236
```
237237

238+
##### hardRejection
239+
240+
Type: `boolean`<br>
241+
Default: `true`
242+
243+
Whether to use [`hard-rejection`](https://github.com/sindresorhus/hard-rejection) or not. Disabling this can be useful if you need to handle `process.on('unhandledRejection')` yourself.
244+
238245
## Promises
239246

240247
Meow will make unhandled rejected promises [fail hard](https://github.com/sindresorhus/hard-rejection) instead of the default silent fail. Meaning you don't have to manually `.catch()` promises used in your CLI.

0 commit comments

Comments
 (0)
Please sign in to comment.