Skip to content
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
5 changes: 4 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,10 @@ function parse (args, opts) {
var value = config[key]
var fullKey = prev ? prev + '.' + key : key

if (Object.prototype.toString.call(value) === '[object Object]') {
// if the value is an inner object and we have dot-notation
// enabled, treat inner objects in config the same as
// heavily nested dot notations (foo.bar.apple).
if (typeof value === 'object' && !Array.isArray(value) && configuration['dot-notation']) {
// if the value is an object but not an array, check nested object
setConfigObject(value, fullKey)
} else {
Expand Down
25 changes: 25 additions & 0 deletions test/yargs-parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -1886,6 +1886,31 @@ describe('yargs-parser', function () {
expect(parsed['foo.bar']).to.equal('banana')
expect(parsed).not.to.include.keys('f.bar')
})

// addresses https://github.com/yargs/yargs/issues/716
it('does not append nested-object keys from config to top-level key', function () {
var parsed = parser([], {
alias: {
'foo': ['f']
},
configuration: {
'dot-notation': false
},
configObjects: [
{
'website.com': {
a: 'b',
b: 'c'
}
}
]
})

parsed['website.com'].should.deep.equal({
a: 'b',
b: 'c'
})
})
})

describe('parse numbers', function () {
Expand Down