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')
console.log(conf.bar)
console.log(conf.bar)
console.log(conf.bar)
async load
loader('./foo.json', function(res){
console.log(res.bar)
})
from cache
loader('./foo.json', true, function(res){
console.log(res.bar)
})
Test
npm test
License
MIT