Skip to content

Commit

Permalink
feat(deps): introduce yargs-parser with support for unknown-options-a…
Browse files Browse the repository at this point in the history
…s-args (#1440)
  • Loading branch information
bcoe authored Oct 7, 2019
1 parent 1b47745 commit 4d21520
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
1 change: 0 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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

0 comments on commit 4d21520

Please sign in to comment.