Created
December 4, 2012 03:32
-
-
Save coryf/4200270 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var _ = require('underscore'); | |
var config = require('../config'); | |
var envPrefix = 'PREFIX_' | |
var envPrefixLen = envPrefix.length; | |
var envKeys = _.chain(config.base).keys().map(function(key){return envPrefix + key;}).value(); | |
var procEnvOverrides = {}; | |
_.chain(process.env).pick(envKeys).each(function(val, key) { | |
var configKey = key.substr(envPrefixLen); | |
procEnvOverrides[configKey] = val; | |
}); | |
var nodeEnvOverrides = config[process.env.NODE_ENV]; | |
module.exports = _.extend(config.base, nodeEnvOverrides, procEnvOverrides); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"base": { | |
"DB_HOST": "localhost", | |
"DB_NAME": "mydb" | |
}, | |
"development": { | |
}, | |
"production": { | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment