Skip to content

Commit

Permalink
Remove hardRejection option
Browse files Browse the repository at this point in the history
Fixes #250
  • Loading branch information
sindresorhus committed Jan 4, 2024
1 parent a7bdf6e commit 99fe7a6
Show file tree
Hide file tree
Showing 6 changed files with 4 additions and 18 deletions.
2 changes: 0 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@
"camelcase-keys",
"decamelize",
"decamelize-keys",
"hard-rejection",
"minimist-options",
"normalize-package-data",
"read-package-up",
Expand All @@ -73,7 +72,6 @@
"delete_comments": "^0.0.2",
"execa": "^8.0.1",
"globby": "^14.0.0",
"hard-rejection": "^2.1.0",
"indent-string": "^5.0.0",
"minimist-options": "4.1.0",
"normalize-package-data": "^6.0.0",
Expand Down
7 changes: 0 additions & 7 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -285,13 +285,6 @@ const cli = meow(`
*/
```

##### hardRejection

Type: `boolean`\
Default: `true`

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.

##### allowUnknownFlags

Type `boolean`\
Expand Down
2 changes: 2 additions & 0 deletions source/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -294,9 +294,11 @@ export type Options<Flags extends AnyFlags> = {
// eslint-disable-next-line @typescript-eslint/ban-types
readonly booleanDefault?: boolean | null | undefined;

// TODO: Remove this in meow 14.
/**
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.
@deprecated This is the default behavior since Node.js 16, so this option is moot.
@default true
*/
readonly hardRejection?: boolean;
Expand Down
6 changes: 0 additions & 6 deletions source/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import parseArguments from 'yargs-parser';
import camelCaseKeys from 'camelcase-keys';
import {trimNewlines} from 'trim-newlines';
import redent from 'redent';
import hardRejection from 'hard-rejection';
import normalizePackageData from 'normalize-package-data';
import {buildOptions} from './options.js';
import {buildParserOptions} from './parser.js';
Expand Down Expand Up @@ -89,11 +88,6 @@ const buildResult = (options, parserOptions) => {

const meow = (helpText, options = {}) => {
const parsedOptions = buildOptions(helpText, options);

if (parsedOptions.hardRejection) {
hardRejection();
}

const parserOptions = buildParserOptions(parsedOptions);
const result = buildResult(parsedOptions, parserOptions);

Expand Down
1 change: 0 additions & 1 deletion source/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ export const buildOptions = (helpText, options) => {
autoHelp: true,
autoVersion: true,
booleanDefault: false,
hardRejection: true,
allowUnknownFlags: true,
allowParentFlags: true,
...options,
Expand Down
4 changes: 2 additions & 2 deletions test-d/build.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ type AnyFlag = NonNullable<NonNullable<Parameters<typeof meow>[0]>['flags']>[str
const importMeta = import.meta;

expectType<Result<never>>(meow('Help text'));
expectType<Result<never>>(meow('Help text', {importMeta, hardRejection: false}));
expectType<Result<never>>(meow('Help text', {importMeta}));
expectAssignable<{flags: {foo: number}}>(
meow({importMeta: import.meta, flags: {foo: {type: 'number', isRequired: true}}}),
);
Expand Down Expand Up @@ -49,7 +49,7 @@ expectType<Result<never>>(meow({importMeta, inferType: true}));
expectType<Result<never>>(meow({importMeta, booleanDefault: true}));
expectType<Result<never>>(meow({importMeta, booleanDefault: null}));
expectType<Result<never>>(meow({importMeta, booleanDefault: undefined}));
expectType<Result<never>>(meow({importMeta, hardRejection: false}));
expectType<Result<never>>(meow({importMeta}));

const result = meow('Help text', {
importMeta,
Expand Down

0 comments on commit 99fe7a6

Please sign in to comment.