Skip to content

Instantly share code, notes, and snippets.

@hpherzog
Created February 24, 2016 18:52
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hpherzog/649c12ea63439e522ac5 to your computer and use it in GitHub Desktop.
Save hpherzog/649c12ea63439e522ac5 to your computer and use it in GitHub Desktop.
Config loader
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