nconf
nconf copied to clipboard
Support stores with configurations defined as objects without prototype
If a memory store is added where the configuration is an object without prototype, when you try to get something the following error occurs:
TypeError: target.hasOwnProperty is not a function
Here is an example to reproduce:
var nconf= require('nconf');
var np = Object.assign(Object.create(null), {key1:'value1'});
nconf.add('np', {type: 'literal', store: np});
console.log(nconf.get('key1'));
Most importantly ini bump to 2.0.0 includes this change https://github.com/npm/ini/commit/032fbaf5f0b98fce70c8cc380e0d05177a9c9073
Which in my project with
nconf.file('defaults', {
file: path.join(rootPath, 'server', 'mas.conf.default'),
format: nconf.formats.ini
});
leads to the same
/Users/ilkkao/git/mas/server/node_modules/nconf/lib/nconf/stores/memory.js:47
if (target && target.hasOwnProperty(key)) {
^
TypeError: target.hasOwnProperty is not a function
at exports.File.Memory.get (/Users/ilkkao/git/mas/server/node_modules/nconf/lib/nconf/stores/memory.js:47:26)
at /Users/ilkkao/git/mas/server/node_modules/nconf/lib/nconf/provider.js:629:32
at Array.forEach (<anonymous>)