Skip to content

Commit

Permalink
Upgrade dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
sindresorhus committed Apr 27, 2021
1 parent 05320ac commit 8c12b2d
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 42 deletions.
19 changes: 10 additions & 9 deletions estest/index.js
@@ -1,16 +1,17 @@
import meow from '../index.js';

meow(`
Usage
$ estest <input>
meow(
`
Usage
$ estest <input>
Options
--rainbow, -r Include a rainbow
Options
--rainbow, -r Include a rainbow
Examples
$ estest unicorns --rainbow
🌈 unicorns 🌈
`,
Examples
$ estest unicorns --rainbow
🌈 unicorns 🌈
`,
{
flags: {
rainbow: {
Expand Down
16 changes: 7 additions & 9 deletions index.d.ts
Expand Up @@ -20,12 +20,11 @@ export interface Flag<Type extends FlagType, Default> {
readonly isMultiple?: boolean;
}

type StringFlag = Flag<'string', string>;
type BooleanFlag = Flag<'boolean', boolean>;
type NumberFlag = Flag<'number', number>;

type AnyFlag = StringFlag | BooleanFlag | NumberFlag;
type AnyFlags = Record<string, AnyFlag>;
type StringFlag = Flag<'string', string>;
type BooleanFlag = Flag<'boolean', boolean>;
type NumberFlag = Flag<'number', number>;
type AnyFlag = StringFlag | BooleanFlag | NumberFlag;
type AnyFlags = Record<string, AnyFlag>;

export interface Options<Flags extends AnyFlags> {
/**
Expand Down Expand Up @@ -209,7 +208,7 @@ export interface Options<Flags extends AnyFlags> {
readonly allowUnknownFlags?: boolean;
}

export type TypedFlag<Flag extends AnyFlag> =
type TypedFlag<Flag extends AnyFlag> =
Flag extends {type: 'number'}
? number
: Flag extends {type: 'string'}
Expand All @@ -218,7 +217,7 @@ export type TypedFlag<Flag extends AnyFlag> =
? boolean
: unknown;

export type PossiblyOptionalFlag<Flag extends AnyFlag, FlagType> =
type PossiblyOptionalFlag<Flag extends AnyFlag, FlagType> =
Flag extends {isRequired: true}
? FlagType
: Flag extends {default: any}
Expand Down Expand Up @@ -306,7 +305,6 @@ const cli = meow(`
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 @@ -45,7 +45,7 @@ const getMissingRequiredFlags = (flags, receivedFlags, input) => {
const reportMissingRequiredFlags = missingRequiredFlags => {
console.error(`Missing required flag${missingRequiredFlags.length > 1 ? 's' : ''}`);
for (const flag of missingRequiredFlags) {
console.error(`\t--${decamelize(flag.key, '-')}${flag.alias ? `, -${flag.alias}` : ''}`);
console.error(`\t--${decamelize(flag.key, {separator: '-'})}${flag.alias ? `, -${flag.alias}` : ''}`);
}
};

Expand Down Expand Up @@ -103,12 +103,12 @@ const meow = (helpText, options) => {
helpText = '';
}

const foundPkg = readPackageUpSync({
const foundPackage = readPackageUpSync({
normalize: false
});

options = {
pkg: foundPkg ? foundPkg.packageJson : {},
pkg: foundPackage ? foundPackage.packageJson : {},
argv: process.argv.slice(2),
flags: {},
inferType: false,
Expand Down Expand Up @@ -154,17 +154,17 @@ const meow = (helpText, options) => {
parserOptions.configuration['unknown-options-as-args'] = true;
}

const {pkg} = options;
const {pkg: package_} = options;
const argv = parseArguments(options.argv, parserOptions);
let help = redent(trimNewlines((options.help || '').replace(/\t+\n*$/, '')), 2);

normalizePackageData(pkg);
normalizePackageData(package_);

process.title = pkg.bin ? Object.keys(pkg.bin)[0] : pkg.name;
process.title = package_.bin ? Object.keys(package_.bin)[0] : package_.name;

let {description} = options;
if (!description && description !== false) {
({description} = pkg);
({description} = package_);
}

help = (description ? `\n ${description}\n` : '') + (help ? `\n${help}\n` : '\n');
Expand All @@ -175,7 +175,7 @@ const meow = (helpText, options) => {
};

const showVersion = () => {
console.log(typeof options.version === 'string' ? options.version : pkg.version);
console.log(typeof options.version === 'string' ? options.version : package_.version);
process.exit(0);
};

Expand Down Expand Up @@ -217,7 +217,7 @@ const meow = (helpText, options) => {
input,
flags,
unnormalizedFlags,
pkg,
pkg: package_,
help,
showHelp,
showVersion
Expand Down
26 changes: 11 additions & 15 deletions package.json
Expand Up @@ -42,35 +42,31 @@
"console"
],
"dependencies": {
"@types/minimist": "^1.2.0",
"@types/minimist": "^1.2.1",
"camelcase-keys": "^6.2.2",
"decamelize": "^1.2.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.0",
"normalize-package-data": "^3.0.2",
"read-pkg-up": "^8.0.0",
"redent": "^3.0.0",
"trim-newlines": "^3.0.0",
"type-fest": "^0.18.0",
"yargs-parser": "^20.2.3"
"trim-newlines": "^4.0.0",
"type-fest": "^1.0.2",
"yargs-parser": "^20.2.7"
},
"devDependencies": {
"ava": "^3.15.0",
"execa": "^4.1.0",
"indent-string": "^4.0.0",
"execa": "^5.0.0",
"indent-string": "^5.0.0",
"read-pkg": "^6.0.0",
"tsd": "^0.13.1",
"tsd": "^0.14.0",
"xo": "^0.39.1"
},
"xo": {
"rules": {
"unicorn/no-process-exit": "off",
"node/no-unsupported-features/es-syntax": "off"
},
"ignores": [
"estest/index.js"
]
"unicorn/no-process-exit": "off"
}
},
"ava": {
"files": [
Expand Down

0 comments on commit 8c12b2d

Please sign in to comment.