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

Override file properties #133

Closed
flatiron32 opened this issue Dec 10, 2014 · 2 comments
Closed

Override file properties #133

flatiron32 opened this issue Dec 10, 2014 · 2 comments

Comments

@flatiron32
Copy link

I have a config file such as
{ "database": { "host": "localhost", "port": "13306", "user": "root" } }

I am calling this in my code:

var nconf = require('nconf');

nconf.argv().env().file({
  file: 'db/config.json'
});

console.log(nconf.get("database:host"));

My assumption was that I would be able to override the value in the config file using an environment variable such as database:host=somethingElse npm test. However either I cannot figure out how to encode the colon or it is not possible to have a colon in an environment key.

How does one override these properties.

@flatiron32
Copy link
Author

I think I have figured it out by setting the logicalSeparator in the env() call to '_' and then setting database_host. Is this documented anywhere outside of the code? If not, I would gladly write some.

I was a little surprised to be bit by using nconf in two files and one overwriting the other.

@flatiron32
Copy link
Author

I also seem to need to call nconf.get() before the override is applied. Is that normal?

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

1 participant