Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #63 from SchoonologyRRL/patch-1

Updated Memory.merge to handle null values
  • Loading branch information...
commit 818526ca62a9b3672e0f394ef2bd0d9a3348e261 2 parents d77c55d + 5d2ebfb
@indexzero authored
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);
}
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.