Created
February 24, 2016 18:52
-
-
Save hpherzog/649c12ea63439e522ac5 to your computer and use it in GitHub Desktop.
Config loader
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'); | |
module.exports.load = function(options) { | |
options = options || {}; | |
var basePath = options.basePath || './config'; | |
var env = options.env || 'development'; | |
var logger = options.logger || console; | |
var filePath = basePath + '/' + env + '.json'; | |
logger.info('Loading config from ' + filePath); | |
var config; | |
try { | |
config = require(filePath); | |
logger.info('Loaded config ' + env); | |
return config; | |
} catch(err) { | |
throw err; | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment