diff --git a/lib/nconf/stores/memory.js b/lib/nconf/stores/memory.js index 6205742..c6553c1 100644 --- a/lib/nconf/stores/memory.js +++ b/lib/nconf/stores/memory.js @@ -157,7 +157,7 @@ Memory.prototype.merge = function (key, value) { // If the key is not an `Object` or is an `Array`, // then simply set it. Merging is for Objects. // - if (typeof value !== 'object' || Array.isArray(value)) { + if (typeof value !== 'object' || Array.isArray(value) || value === null) { return this.set(key, value); } diff --git a/test/fixtures/merge/file1.json b/test/fixtures/merge/file1.json index b48f5c0..f9e1ca9 100644 --- a/test/fixtures/merge/file1.json +++ b/test/fixtures/merge/file1.json @@ -12,5 +12,8 @@ "first": 1, "second": 2 } + }, + "unicorn": { + "exists": true } } diff --git a/test/fixtures/merge/file2.json b/test/fixtures/merge/file2.json index 815779c..7940cb9 100644 --- a/test/fixtures/merge/file2.json +++ b/test/fixtures/merge/file2.json @@ -5,5 +5,6 @@ "something4": true }, "dates": true, - "elderberries": true -} \ No newline at end of file + "elderberries": true, + "unicorn": null +} diff --git a/test/provider-test.js b/test/provider-test.js index 78ee97d..0805369 100644 --- a/test/provider-test.js +++ b/test/provider-test.js @@ -84,6 +84,11 @@ vows.describe('nconf/provider').addBatch({ provider.merge(override); helpers.assertMerged(null, provider.stores.file.store); assert.equal(provider.stores.file.store.candy.something, 'file1'); + }, + "should merge Objects over null": function (provider) { + provider.load(); + provider.merge(override); + assert.equal(provider.stores.file.store.unicorn.exists, true); } } }