Skip to content

Commit

Permalink
fix: allow null config values (yargs#108)
Browse files Browse the repository at this point in the history
  • Loading branch information
zyrolasting authored and bcoe committed Dec 1, 2017
1 parent c7eee91 commit d8b14f9
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion index.js
Expand Up @@ -479,7 +479,7 @@ function parse (args, opts) {
// 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 (typeof value === 'object' && value !== null && !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
4 changes: 3 additions & 1 deletion test/yargs-parser.js
Expand Up @@ -642,13 +642,15 @@ describe('yargs-parser', function () {
configObjects: [{
apple: 'apple',
banana: 42,
foo: 'baz'
foo: 'baz',
gotcha: null
}]
})

argv.should.have.property('apple', 'apple')
argv.should.have.property('banana', 42)
argv.should.have.property('foo', 'bar')
argv.should.have.property('gotcha', null)
})

it('should use value from config object, if argv value is using default value', function () {
Expand Down

0 comments on commit d8b14f9

Please sign in to comment.