Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions lib/nconf/provider.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,9 @@ Provider.prototype.use = function (name, options) {
var store = this.stores[name],
update = store && !sameOptions(store);

if (!store || update) {
if (update) {
this.remove(name);
}

if (!store) {
this.add(name, options);
} else if (store && update) {
this.add(name, options);
}

Expand Down
10 changes: 9 additions & 1 deletion test/provider-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,15 @@ vows.describe('nconf/provider').addBatch({
"when 'env' is set to true with a nested separator": helpers.assertSystemConf({
script: path.join(fixturesDir, 'scripts', 'nconf-nested-env.js'),
env: { SOME_THING: 'foobar' }
})
}),
"calling the use() method after adding other stores": {
topic: new nconf.Provider().use('file', { file: files[0] }).defaults({candy: {something: 'should never get this'}}),
"should use a new instance of the store type": function (provider) {
provider.use('file', { file: files[1] });

assert.equal(provider.get('candy:something'), 'file2');
}
},
}
}
}).addBatch({
Expand Down