Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

precedence of .file() calls not as expected #121

Closed
fschwiet opened this issue Aug 7, 2014 · 3 comments
Closed

precedence of .file() calls not as expected #121

fschwiet opened this issue Aug 7, 2014 · 3 comments

Comments

@fschwiet
Copy link

fschwiet commented Aug 7, 2014

The documentation seems to state that parameters from calls to .argv()/.env()/.file() take precedence based on the order they are called (with the first taking precedence

I find that if I have multiple .file() calls, the later .file() calls take precedence, when documentation indicates the first should. The below code gives a final value of 2, though I'd expect 1 (from the first file) to be the actual value.

var fs = require("fs");
var path = require("path");

var first = path.resolve("./first.json");
var second = path.resolve("./second.json");

fs.writeFileSync(first, JSON.stringify({"abc" : 1, "def": 1}, null, 4));
fs.writeFileSync(second, JSON.stringify({"abc" : 2, "def": 1}));

var nconf = require("nconf");

nconf.file({ file : first})
nconf.file({ file : second});

console.log("value is:", nconf.get("abc"));
@fschwiet fschwiet changed the title precedence of .file() calls note as expected precedence of .file() calls not as expected Aug 7, 2014
@fschwiet
Copy link
Author

fschwiet commented Aug 7, 2014

Oh, it looks like multiple calls to .file() don't merge values from the files (if the last file doesn't have a value, values from previous files are ignored). So perhaps only the last file is being used...

@vegar
Copy link

vegar commented Aug 7, 2014

You're not the first ;-)
#97 #109 #110 #117

@fschwiet
Copy link
Author

fschwiet commented Aug 7, 2014

My bad for not searching.

@fschwiet fschwiet closed this as completed Aug 7, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants