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
a1f5f0f
commit fc33c0f
Showing
5 changed files
with
77 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,23 @@ | ||
import test from 'ava'; | ||
import execa from 'execa'; | ||
const path = require('path'); | ||
|
||
const fixtureAllowUnknownFlags = path.join(__dirname, 'fixtures', 'fixture-allow-unknown-flags.js'); | ||
|
||
test('spawn cli and test specifying unknown flags', async t => { | ||
try { | ||
await execa(fixtureAllowUnknownFlags, ['--foo', 'bar', '--unspecified-a', '--unspecified-b', 'input-is-allowed']); | ||
} catch (error) { | ||
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); |