diff --git a/index.js b/index.js index c06d9370..1a2c7cb5 100644 --- a/index.js +++ b/index.js @@ -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 { diff --git a/test/yargs-parser.js b/test/yargs-parser.js index d2d56545..0c9bb97c 100644 --- a/test/yargs-parser.js +++ b/test/yargs-parser.js @@ -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 () {