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

Add support for nested configs via env #49

Merged
merged 5 commits into from
Jun 21, 2012
Merged

Add support for nested configs via env #49

merged 5 commits into from
Jun 21, 2012

Conversation

mhart
Copy link
Contributor

@mhart mhart commented Jun 21, 2012

This allows you to use nested config keys from env variables by specifying a custom separator (I believe this isn't currently possible because you can't use the : character in env variable names).

console.log(require('nconf').env('__').get('SOME:THING'));
$ SOME__THING=whatever node example.js
whatever

@@ -183,7 +183,7 @@ Memory.prototype.merge = function (key, value) {
}

return Object.keys(value).every(function (nested) {
return self.merge(fullKey + ':' + nested, value[nested]);
return self.merge(common.key(fullKey, nested), value[nested]);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change was just so that the only place where the : character is referenced is in common - plus, it seems like the right thing to do

@jfhbrook
Copy link
Contributor

Nice! I approve.

@pksunkara Can you run tests and merge on this? I'm about to hit the hay.

pksunkara added a commit that referenced this pull request Jun 21, 2012
Add support for nested configs via env
@pksunkara pksunkara merged commit 6dd2351 into indexzero:master Jun 21, 2012
@indexzero
Copy link
Owner

@pksunkara @jesusabdullah @mhart This introduced a pretty serious regression in #65. Be more careful in the future

@mhart mhart deleted the nested-env-configs branch December 20, 2012 21:53
@mhart
Copy link
Contributor Author

mhart commented Dec 20, 2012

I really have no idea how this issue is at all related to #65, but the irony of telling people to Be more careful in the future is not lost on me.

@mhart mhart mentioned this pull request Dec 20, 2012
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

Successfully merging this pull request may close these issues.

None yet

4 participants