Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(deps): introduce yargs-parser with support for unknown-options-as-args #1440

Merged
merged 1 commit into from Oct 7, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 0 additions & 1 deletion CHANGELOG.md
Expand Up @@ -18,7 +18,6 @@ All notable changes to this project will be documented in this file. See [standa
### Features

* make it possible to merge configurations when extending other config. ([#1411](https://github.com/yargs/yargs/issues/1411)) ([5d7ad98](https://github.com/yargs/yargs/commit/5d7ad98))
* **deps:** yargs-parser with support for collect-unknown-options ([#1421](https://github.com/yargs/yargs/issues/1421)) ([d388a7c](https://github.com/yargs/yargs/commit/d388a7c))

## [14.0.0](https://github.com/yargs/yargs/compare/v13.3.0...v14.0.0) (2019-07-30)

Expand Down
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -29,7 +29,7 @@
"string-width": "^3.0.0",
"which-module": "^2.0.0",
"y18n": "^4.0.0",
"yargs-parser": "^14.0.0"
"yargs-parser": "^15.0.0"
},
"devDependencies": {
"chai": "^4.2.0",
Expand Down
17 changes: 16 additions & 1 deletion test/yargs.js
Expand Up @@ -1725,13 +1725,28 @@ describe('yargs dsl tests', () => {
})

describe('parserConfiguration', () => {
it('overrides the default parser configuration ', () => {
it('overrides the default parser configuration', () => {
const argv = yargs('--foo.bar 1 --no-baz 2')
.parserConfiguration({ 'boolean-negation': false, 'dot-notation': false })
.parse()
expect(argv['foo.bar']).to.equal(1)
argv.noBaz.should.equal(2)
})

it('supports --unknown-options-as-args', () => {
const argv = yargs('--foo.bar 1 --no-baz 2')
.parserConfiguration({ 'unknown-options-as-args': true })
.parse()
argv._.should.deep.eql(['--foo.bar', '1', '--no-baz', '2'])
const argv2 = yargs('foo --foo.bar --cool 1 --no-baz 2')
.command('foo', 'my foo command', (yargs) => {
yargs.boolean('cool')
}, () => {})
.parserConfiguration({ 'unknown-options-as-args': true })
.parse()
argv2._.should.deep.eql(['foo', '--foo.bar', '1', '--no-baz', '2'])
argv2.cool.should.equal(true)
})
})

describe('skipValidation', () => {
Expand Down