New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More

env-conf-loader

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

env-conf-loader

auto load config file/directory with env


Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created

evn-conf-loader

NPM Version NPM Downloads Build Status Test Coverage

中文文档

Why?

load configs from file/directory with current, merge object by object's key and environment variable.

Install

npm install evn-conf-loader

Usage

var loader = require('evn-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

License

MIT

FAQs

Package last updated on 04 Feb 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts