Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a0ce744
commit 30c2e44
Showing
5 changed files
with
74 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import path from 'path'; | ||
import test from 'ava'; | ||
import execa from 'execa'; | ||
|
||
const fixtureAllowUnknownFlags = path.join(__dirname, 'fixtures', 'fixture-allow-unknown-flags.js'); | ||
|
||
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']) | ||
); | ||
const {stderr, message} = error; | ||
t.regex(message, /Command failed with exit code 2/); | ||
t.regex(stderr, /Unknown flag/); | ||
t.regex(stderr, /--unspecified-a/); | ||
t.regex(stderr, /--unspecified-b/); | ||
t.notRegex(stderr, /input-is-allowed/); | ||
}); | ||
|
||
test('spawn CLI and test specifying known flags', async t => { | ||
const {stdout} = await execa(fixtureAllowUnknownFlags, ['--foo', 'bar']); | ||
t.is(stdout, 'bar'); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#!/usr/bin/env node | ||
'use strict'; | ||
const meow = require('../..'); | ||
|
||
const cli = meow({ | ||
description: 'Custom description', | ||
help: ` | ||
Usage | ||
foo <input> | ||
`, | ||
allowUnknownFlags: false, | ||
flags: { | ||
foo: { | ||
type: 'string' | ||
} | ||
} | ||
}); | ||
|
||
console.log(cli.flags.foo); |