Last active
August 29, 2015 14:07
-
-
Save charlesponti/7f26d91c8d6c93d02aba to your computer and use it in GitHub Desktop.
Load a JSON config file based on NodeJS environment
This file contains hidden or 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 fs = require('fs'); | |
| var path = require('path'); | |
| var env = process.env.NODE_ENV; | |
| var configFile = path.resolve(__dirname, './environments/'+env+'.json'); | |
| var config = JSON.parse(fs.readFileSync(configFile)); | |
| Object.keys(config).forEach(function(key) { | |
| process.env[key] = config[key]; | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment