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

Fix: setConfigObject() with array typed options and alias/camel-case #199

Merged
merged 1 commit into from
Aug 20, 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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -555,7 +555,7 @@ function parse (args, opts) {
} else {
// setting arguments via CLI takes precedence over
// values within the config file.
if (!hasKey(argv, fullKey.split('.')) || (flags.arrays[fullKey] && configuration['combine-arrays'])) {
if (!hasKey(argv, fullKey.split('.')) || (checkAllAliases(fullKey, flags.arrays) && configuration['combine-arrays'])) {
setArg(fullKey, value)
}
}
Expand Down
15 changes: 15 additions & 0 deletions test/yargs-parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -774,6 +774,21 @@ describe('yargs-parser', function () {
argv.should.have.property('foo', 'bar')
argv.should.have.property('bar', 'baz')
})

it('should combine array typed options with alias and camel-case', function () {
var argv = parser(['--camEl', 'foo', '--camEl', 'bar', '-a', 'red'], {
array: ['cam-el', 'apple'],
alias: { apple: 'a' },
configObjects: [{ camEl: 'baz' }, { a: 'sweet' }],
configuration: {
'combine-arrays': true,
'camel-case-expansion': true
}
})

argv['cam-el'].should.deep.equal(['foo', 'bar', 'baz'])
argv.apple.should.deep.equal(['red', 'sweet'])
})
})

describe('dot notation', function () {
Expand Down