Skip to content

Updated Memory.merge to handle null values #63

Merged
merged 2 commits into from Dec 21, 2012
View
2 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);
}
View
3 test/fixtures/merge/file1.json
@@ -12,5 +12,8 @@
"first": 1,
"second": 2
}
+ },
+ "unicorn": {
+ "exists": true
}
}
View
5 test/fixtures/merge/file2.json
@@ -5,5 +5,6 @@
"something4": true
},
"dates": true,
- "elderberries": true
-}
+ "elderberries": true,
+ "unicorn": null
+}
View
5 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);
}
}
}
Something went wrong with that request. Please try again.