-
Notifications
You must be signed in to change notification settings - Fork 253
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
using multiple .files() ? #110
Comments
+1 - I've just noticed this has been replacing parts of my config files. My config files are: default.json: Bare bones config, things that would otherwise need to be duplicated between all 'environment specific configs' (production | stage | development).json: Environment specific configs, DB address etc overrides.json: This is a special config file which can be updated, it is not included in the code repository like the other files. I specify How would you advise I go about this? |
Temporary workaround:
|
- Update the Readme with notes that when using multiple config files, the user must use a custom key as the first parameter in additional nconf.file() calls in order for config heirarchy/inheritance to work properly. Fixes indexzero#97, Fixes indexzero#109, Fixes indexzero#110
I ran into a situation that the name of the store being "overrides" and "defaults" completely wipes out the stores for the call @vegar is this correct? I did the following to prevent that: /**
* Loads a given file based on the name.
*
* @param {string} appConfigDir the path to the file.
* @param {string} fileName the name of the file.
* @param {string} format is the format to be loaded.
*/
function _loadFile(appConfigDir, fileName, format) {
var filePath = path.resolve(appConfigDir, fileName + "." + format);
log.debug("Attempting to load the " + fileName + " file at " + filePath);
if (format === "json") {
nconf.file(fileName + "-store", filePath);
} else {
// load a yaml file using a custom formatter
// https://gist.github.com/clarkdave/f31d92ca88d11ef5340c
nconf.file({
file: filePath + "-store",
format: {
parse: yaml.safeLoad,
stringify: yaml.safeDump,
}
});
}
} |
I am trying to use two calls to file(), in the hope any elements present in one file will override those in the other
If I util.inspect(nconf) it seems like the stores object is only able to hold one file store at a time, so nconf.json is being replaced entirely by host.json.
Is this a known issue, or have I misunderstood something?
The text was updated successfully, but these errors were encountered: