env-conf-loader
v0.1.2
Published
auto load config file/directory with env
Downloads
7
Readme
env-conf-loader
Why?
load configs from file/directory with current, merge object by object's key and environment variable.
Install
npm install env-conf-loader
Usage
var loader = require('env-conf-loader')
load a json file
foo.json
{
"bar": 0,
"default": { "bar": 1 },
"production": { "bar": 2, },
"development": { "bar": 3, }
}
var conf = loader('./foo.json')
// NODE_ENV is undefined
console.log(conf.bar) // 1
// NODE_ENV is production
console.log(conf.bar) // 2
// NODE_ENV is development
console.log(conf.bar) // 3
async load
loader('./foo.json', function(res){
console.log(res.bar) // 1
})
from cache
loader('./foo.json', true, function(res){
console.log(res.bar) // 2
})
Test
npm test