Skip to content

Commit

Permalink
Upgrade dependencies
Browse files Browse the repository at this point in the history
Fixes #192
  • Loading branch information
sindresorhus committed Jul 15, 2021
1 parent ae73466 commit 829aab0
Show file tree
Hide file tree
Showing 14 changed files with 171 additions and 175 deletions.
8 changes: 4 additions & 4 deletions estest/index.js
Expand Up @@ -17,8 +17,8 @@ meow(
flags: {
rainbow: {
type: 'boolean',
alias: 'r'
}
}
}
alias: 'r',
},
},
},
);
1 change: 0 additions & 1 deletion index.d.ts
Expand Up @@ -313,5 +313,4 @@ foo(cli.input[0], cli.flags);
```
*/
export default function meow<Flags extends AnyFlags>(helpMessage: string, options?: Options<Flags>): Result<Flags>;
// eslint-disable-next-line no-redeclare
export default function meow<Flags extends AnyFlags>(options?: Options<Flags>): Result<Flags>;
18 changes: 9 additions & 9 deletions index.js
Expand Up @@ -61,7 +61,7 @@ const validateOptions = ({flags}) => {
const reportUnknownFlags = unknownFlags => {
console.error([
`Unknown flag${unknownFlags.length > 1 ? 's' : ''}`,
...unknownFlags
...unknownFlags,
].join('\n'));
};

Expand All @@ -72,9 +72,9 @@ const buildParserFlags = ({flags, booleanDefault}) => {
const flag = {...flagValue};

if (
typeof booleanDefault !== 'undefined' &&
flag.type === 'boolean' &&
!Object.prototype.hasOwnProperty.call(flag, 'default')
typeof booleanDefault !== 'undefined'
&& flag.type === 'boolean'
&& !Object.prototype.hasOwnProperty.call(flag, 'default')
) {
flag.default = flag.isMultiple ? [booleanDefault] : booleanDefault;
}
Expand Down Expand Up @@ -111,7 +111,7 @@ const meow = (helpText, options = {}) => {

const foundPackage = readPackageUpSync({
cwd: dirname(fileURLToPath(options.importMeta.url)),
normalize: false
normalize: false,
});

options = {
Expand All @@ -126,7 +126,7 @@ const meow = (helpText, options = {}) => {
booleanDefault: false,
hardRejection: true,
allowUnknownFlags: true,
...options
...options,
};

if (options.hardRejection) {
Expand All @@ -136,7 +136,7 @@ const meow = (helpText, options = {}) => {
validateOptions(options);
let parserOptions = {
arguments: options.input,
...buildParserFlags(options)
...buildParserFlags(options),
};

parserOptions = decamelizeKeys(parserOptions, '-', {exclude: ['stopEarly', '--']});
Expand All @@ -149,7 +149,7 @@ const meow = (helpText, options = {}) => {

parserOptions.configuration = {
...parserOptions.configuration,
'greedy-arrays': false
'greedy-arrays': false,
};

if (parserOptions['--']) {
Expand Down Expand Up @@ -227,7 +227,7 @@ const meow = (helpText, options = {}) => {
pkg: package_,
help,
showHelp,
showVersion
showVersion,
};
};

Expand Down
28 changes: 14 additions & 14 deletions index.test-d.ts
Expand Up @@ -7,31 +7,31 @@ const importMeta = import.meta;
expectType<Result<never>>(meow('Help text'));
expectType<Result<never>>(meow('Help text', {importMeta, hardRejection: false}));
expectAssignable<{flags: {foo: number}}>(
meow({importMeta: import.meta, flags: {foo: {type: 'number', isRequired: true}}})
meow({importMeta: import.meta, flags: {foo: {type: 'number', isRequired: true}}}),
);
expectAssignable<{flags: {foo: string}}>(
meow({importMeta, flags: {foo: {type: 'string', isRequired: true}}})
meow({importMeta, flags: {foo: {type: 'string', isRequired: true}}}),
);
expectAssignable<{flags: {foo: boolean}}>(
meow({importMeta, flags: {foo: {type: 'boolean', isRequired: true}}})
meow({importMeta, flags: {foo: {type: 'boolean', isRequired: true}}}),
);
expectAssignable<{flags: {foo: number | undefined}}>(
meow({importMeta, flags: {foo: {type: 'number'}}})
meow({importMeta, flags: {foo: {type: 'number'}}}),
);
expectAssignable<{flags: {foo: string | undefined}}>(
meow({importMeta, flags: {foo: {type: 'string'}}})
meow({importMeta, flags: {foo: {type: 'string'}}}),
);
expectAssignable<{flags: {foo: boolean | undefined}}>(
meow({importMeta, flags: {foo: {type: 'boolean'}}})
meow({importMeta, flags: {foo: {type: 'boolean'}}}),
);
expectAssignable<{flags: {foo: number[] | undefined}}>(
meow({importMeta, flags: {foo: {type: 'number', isMultiple: true}}})
meow({importMeta, flags: {foo: {type: 'number', isMultiple: true}}}),
);
expectAssignable<{flags: {foo: string[] | undefined}}>(
meow({importMeta, flags: {foo: {type: 'string', isMultiple: true}}})
meow({importMeta, flags: {foo: {type: 'string', isMultiple: true}}}),
);
expectAssignable<{flags: {foo: boolean[] | undefined}}>(
meow({importMeta, flags: {foo: {type: 'boolean', isMultiple: true}}})
meow({importMeta, flags: {foo: {type: 'boolean', isMultiple: true}}}),
);
expectType<Result<never>>(meow({importMeta, description: 'foo'}));
expectType<Result<never>>(meow({importMeta, description: false}));
Expand All @@ -55,8 +55,8 @@ const result = meow('Help text', {
foo: {type: 'boolean', alias: 'f'},
'foo-bar': {type: 'number'},
bar: {type: 'string', default: ''},
abc: {type: 'string', isMultiple: true}
}
abc: {type: 'string', isMultiple: true},
},
});

expectType<string[]>(result.input);
Expand All @@ -82,9 +82,9 @@ const options = {
flags: {
rainbow: {
type: 'boolean',
alias: 'r'
}
}
alias: 'r',
},
},
} as const;

meow('', options);
Expand Down
16 changes: 8 additions & 8 deletions package.json
Expand Up @@ -42,26 +42,26 @@
"console"
],
"dependencies": {
"@types/minimist": "^1.2.1",
"camelcase-keys": "^6.2.2",
"@types/minimist": "^1.2.2",
"camelcase-keys": "^7.0.0",
"decamelize": "^5.0.0",
"decamelize-keys": "^1.1.0",
"hard-rejection": "^2.1.0",
"minimist-options": "4.1.0",
"normalize-package-data": "^3.0.2",
"read-pkg-up": "^8.0.0",
"redent": "^4.0.0",
"trim-newlines": "^4.0.1",
"type-fest": "^1.0.2",
"yargs-parser": "^20.2.7"
"trim-newlines": "^4.0.2",
"type-fest": "^1.2.2",
"yargs-parser": "^20.2.9"
},
"devDependencies": {
"ava": "^3.15.0",
"execa": "^5.0.0",
"execa": "^5.1.1",
"indent-string": "^5.0.0",
"read-pkg": "^6.0.0",
"tsd": "^0.14.0",
"xo": "^0.39.1"
"tsd": "^0.17.0",
"xo": "^0.41.0"
},
"xo": {
"rules": {
Expand Down
4 changes: 2 additions & 2 deletions test/allow-unkonwn-flags.js
Expand Up @@ -10,8 +10,8 @@ test('spawn CLI and test specifying unknown flags', async t => {
const error = await t.throwsAsync(
execa(fixtureAllowUnknownFlags, ['--foo', 'bar', '--unspecified-a', '--unspecified-b', 'input-is-allowed']),
{
message: /^Command failed with exit code 2/
}
message: /^Command failed with exit code 2/,
},
);
const {stderr} = error;
t.regex(stderr, /Unknown flags/);
Expand Down
6 changes: 3 additions & 3 deletions test/fixtures/fixture-allow-unknown-flags.js
Expand Up @@ -11,9 +11,9 @@ const cli = meow({
allowUnknownFlags: false,
flags: {
foo: {
type: 'string'
}
}
type: 'string',
},
},
});

console.log(cli.flags.foo);
14 changes: 6 additions & 8 deletions test/fixtures/fixture-required-function.js
Expand Up @@ -11,17 +11,15 @@ const cli = meow({
flags: {
trigger: {
type: 'boolean',
alias: 't'
alias: 't',
},
withTrigger: {
type: 'string',
isRequired: (flags, _) => {
return flags.trigger;
}
isRequired: (flags, _) => flags.trigger,
},
allowError: {
type: 'boolean',
alias: 'a'
alias: 'a',
},
shouldError: {
type: 'boolean',
Expand All @@ -31,9 +29,9 @@ const cli = meow({
}

return false;
}
}
}
},
},
},
});

console.log(`${cli.flags.trigger},${cli.flags.withTrigger}`);
6 changes: 3 additions & 3 deletions test/fixtures/fixture-required-multiple.js
Expand Up @@ -13,9 +13,9 @@ const cli = meow({
type: 'number',
alias: 't',
isRequired: true,
isMultiple: true
}
}
isMultiple: true,
},
},
});

console.log(cli.flags.test);
13 changes: 6 additions & 7 deletions test/fixtures/fixture-required.js
@@ -1,5 +1,4 @@
#!/usr/bin/env node
'use strict';
import meow from '../../index.js';

const cli = meow({
Expand All @@ -13,20 +12,20 @@ const cli = meow({
test: {
type: 'string',
alias: 't',
isRequired: true
isRequired: true,
},
number: {
type: 'number',
isRequired: true
isRequired: true,
},
kebabCase: {
type: 'string',
isRequired: true
isRequired: true,
},
notRequired: {
type: 'string'
}
}
type: 'string',
},
},
});

console.log(`${cli.flags.test},${cli.flags.number}`);
4 changes: 2 additions & 2 deletions test/fixtures/fixture.js
Expand Up @@ -13,8 +13,8 @@ const cli = meow({
flags: {
unicorn: {alias: 'u'},
meow: {default: 'dog'},
camelCaseOption: {default: 'foo'}
}
camelCaseOption: {default: 'foo'},
},
});

if (cli.flags.camelCaseOption === 'foo') {
Expand Down
2 changes: 1 addition & 1 deletion test/is-required-flag.js
Expand Up @@ -29,7 +29,7 @@ test('spawn cli and test specifying all required flags', async t => {
'--number',
'6',
'--kebab-case',
'test'
'test',
]);
t.is(stdout, 'test,6');
});
Expand Down

0 comments on commit 829aab0

Please sign in to comment.