From 99fe7a601c375ee1d070ef80b1664424b669238b Mon Sep 17 00:00:00 2001 From: Sindre Sorhus Date: Thu, 4 Jan 2024 08:45:03 +0700 Subject: [PATCH] Remove `hardRejection` option Fixes #250 --- package.json | 2 -- readme.md | 7 ------- source/index.d.ts | 2 ++ source/index.js | 6 ------ source/options.js | 1 - test-d/build.test-d.ts | 4 ++-- 6 files changed, 4 insertions(+), 18 deletions(-) diff --git a/package.json b/package.json index 4e32da3..7a79802 100644 --- a/package.json +++ b/package.json @@ -51,7 +51,6 @@ "camelcase-keys", "decamelize", "decamelize-keys", - "hard-rejection", "minimist-options", "normalize-package-data", "read-package-up", @@ -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", diff --git a/readme.md b/readme.md index d6a9eeb..6e6146f 100644 --- a/readme.md +++ b/readme.md @@ -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`\ diff --git a/source/index.d.ts b/source/index.d.ts index b7c240b..427e1ae 100644 --- a/source/index.d.ts +++ b/source/index.d.ts @@ -294,9 +294,11 @@ export type Options = { // 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; diff --git a/source/index.js b/source/index.js index 3bc1865..e71aaad 100644 --- a/source/index.js +++ b/source/index.js @@ -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'; @@ -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); diff --git a/source/options.js b/source/options.js index 2c7d5cd..8a331cf 100644 --- a/source/options.js +++ b/source/options.js @@ -78,7 +78,6 @@ export const buildOptions = (helpText, options) => { autoHelp: true, autoVersion: true, booleanDefault: false, - hardRejection: true, allowUnknownFlags: true, allowParentFlags: true, ...options, diff --git a/test-d/build.test-d.ts b/test-d/build.test-d.ts index ca9d8ee..29ec7de 100644 --- a/test-d/build.test-d.ts +++ b/test-d/build.test-d.ts @@ -7,7 +7,7 @@ type AnyFlag = NonNullable[0]>['flags']>[str const importMeta = import.meta; expectType>(meow('Help text')); -expectType>(meow('Help text', {importMeta, hardRejection: false})); +expectType>(meow('Help text', {importMeta})); expectAssignable<{flags: {foo: number}}>( meow({importMeta: import.meta, flags: {foo: {type: 'number', isRequired: true}}}), ); @@ -49,7 +49,7 @@ expectType>(meow({importMeta, inferType: true})); expectType>(meow({importMeta, booleanDefault: true})); expectType>(meow({importMeta, booleanDefault: null})); expectType>(meow({importMeta, booleanDefault: undefined})); -expectType>(meow({importMeta, hardRejection: false})); +expectType>(meow({importMeta})); const result = meow('Help text', { importMeta,