Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: sindresorhus/meow
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v10.1.2
Choose a base ref
...
head repository: sindresorhus/meow
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v10.1.3
Choose a head ref
  • 4 commits
  • 10 files changed
  • 3 contributors

Commits on Jan 20, 2022

  1. Fix readme typo

    sindresorhus committed Jan 20, 2022

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    aede62e View commit details

Commits on Apr 21, 2022

  1. Bump dev dependencies (#207)

    Co-authored-by: Sindre Sorhus <sindresorhus@gmail.com>
    LitoMore and sindresorhus authored Apr 21, 2022
    Copy the full SHA
    bc489b4 View commit details

Commits on Jun 21, 2022

  1. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    db55316 View commit details
  2. 10.1.3

    sindresorhus committed Jun 21, 2022
    Copy the full SHA
    85dc1e9 View commit details
Showing with 24 additions and 21 deletions.
  1. +4 −2 .github/workflows/main.yml
  2. +2 −1 index.d.ts
  3. +2 −0 index.js
  4. +5 −5 package.json
  5. +1 −1 readme.md
  6. +1 −1 test/allow-unkonwn-flags.js
  7. +3 −7 test/fixtures/fixture-required-function.js
  8. +1 −0 test/fixtures/fixture.js
  9. +1 −1 test/is-required-flag.js
  10. +4 −3 test/test.js
6 changes: 4 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -10,10 +10,12 @@ jobs:
fail-fast: false
matrix:
node-version:
- 18
- 16
- 14
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- run: npm install
3 changes: 2 additions & 1 deletion index.d.ts
Original file line number Diff line number Diff line change
@@ -197,6 +197,7 @@ export interface Options<Flags extends AnyFlags> {
//}
```
*/
// eslint-disable-next-line @typescript-eslint/ban-types
readonly booleanDefault?: boolean | null | undefined;

/**
@@ -267,7 +268,7 @@ export interface Result<Flags extends AnyFlags> {
@param exitCode - The exit code to use. Default: `2`.
*/
showHelp: (exitCode?: number) => void;
showHelp: (exitCode?: number) => never;

/**
Show the version text and exit.
2 changes: 2 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {dirname} from 'node:path';
import process from 'node:process';
import {fileURLToPath} from 'node:url';
import buildParserOptions from 'minimist-options';
import parseArguments from 'yargs-parser';
@@ -99,6 +100,7 @@ const validateFlags = (flags, options) => {
}
};

/* eslint complexity: off */
const meow = (helpText, options = {}) => {
if (typeof helpText !== 'string') {
options = helpText;
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "meow",
"version": "10.1.2",
"version": "10.1.3",
"description": "CLI app helper",
"license": "MIT",
"repository": "sindresorhus/meow",
@@ -57,11 +57,11 @@
},
"devDependencies": {
"ava": "^3.15.0",
"execa": "^5.1.1",
"execa": "^6.1.0",
"indent-string": "^5.0.0",
"read-pkg": "^6.0.0",
"tsd": "^0.17.0",
"xo": "^0.41.0"
"read-pkg": "^7.1.0",
"tsd": "^0.20.0",
"xo": "^0.48.0"
},
"xo": {
"rules": {
2 changes: 1 addition & 1 deletion readme.md
Original file line number Diff line number Diff line change
@@ -285,7 +285,7 @@ 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
##### allowUnknownFlags

Type `boolean`\
Default: `true`
2 changes: 1 addition & 1 deletion test/allow-unkonwn-flags.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import path from 'node:path';
import {fileURLToPath} from 'node:url';
import test from 'ava';
import execa from 'execa';
import {execa} from 'execa';

const __dirname = path.dirname(fileURLToPath(import.meta.url));
const fixtureAllowUnknownFlags = path.join(__dirname, 'fixtures', 'fixture-allow-unknown-flags.js');
10 changes: 3 additions & 7 deletions test/fixtures/fixture-required-function.js
Original file line number Diff line number Diff line change
@@ -23,13 +23,9 @@ const cli = meow({
},
shouldError: {
type: 'boolean',
isRequired: (flags, _) => {
if (flags.allowError) {
return 'should error';
}

return false;
},
isRequired: (flags, _) =>
flags.allowError ? 'should error' : false
,
},
},
});
1 change: 1 addition & 0 deletions test/fixtures/fixture.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env node
import process from 'node:process';
import meow from '../../index.js';

const cli = meow({
2 changes: 1 addition & 1 deletion test/is-required-flag.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import path from 'node:path';
import {fileURLToPath} from 'node:url';
import test from 'ava';
import execa from 'execa';
import {execa} from 'execa';

const __dirname = path.dirname(fileURLToPath(import.meta.url));
const fixtureRequiredPath = path.join(__dirname, 'fixtures', 'fixture-required.js');
7 changes: 4 additions & 3 deletions test/test.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import path from 'node:path';
import process from 'node:process';
import {fileURLToPath} from 'node:url';
import test from 'ava';
import indentString from 'indent-string';
import execa from 'execa';
import {readPackageAsync} from 'read-pkg';
import {execa} from 'execa';
import {readPackage} from 'read-pkg';
import meow from '../index.js';

const __dirname = path.dirname(fileURLToPath(import.meta.url));
@@ -55,7 +56,7 @@ test('support help shortcut', t => {
});

test('spawn cli and show version', async t => {
const pkg = await readPackageAsync();
const pkg = await readPackage();
const {stdout} = await execa(fixturePath, ['--version']);
t.is(stdout, pkg.version);
});