Skip to content

Instantly share code, notes, and snippets.

@esundahl
Forked from tj/config.js
Last active December 27, 2015 14:49
Show Gist options
  • Save esundahl/7343622 to your computer and use it in GitHub Desktop.
Save esundahl/7343622 to your computer and use it in GitHub Desktop.
#javascript #node.js
/**
* Module dependencies.
*/
var pkg = require('../package');
var env = process.env.NODE_ENV || 'development';
/**
* Return setting `name`.
*
* @param {String} name
* @return {Mixed}
* @api public
*/
module.exports = function(name){
console.log(pkg[env]);
if (null == pkg[env]) throw new Error('invalid configuration environment "' + env + '"');
if (null == pkg[env][name]) throw new Error('invalid configuration key "' + name + '"');
return pkg[env][name];
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment