Comparing version 2.1.6 to 2.2.0
{ | ||
"name": "cnf", | ||
"version": "2.1.6", | ||
"version": "2.2.0", | ||
"description": "Configuration loader", | ||
@@ -9,11 +9,12 @@ "scripts": { | ||
"devDependencies": { | ||
"mocha": "~2.1.0", | ||
"chai": "~1.10.0", | ||
"sinon": "~1.12.2", | ||
"sinon-chai": "~2.6.0", | ||
"mocha-jshint": "~0.0.9" | ||
"chai": "^2.2.0", | ||
"mocha": "^2.2.1", | ||
"mocha-jshint": "^1.0.0", | ||
"sinon": "^1.14.1", | ||
"sinon-chai": "^2.7.0" | ||
}, | ||
"main": "./source/config.js", | ||
"dependencies": { | ||
"resolve": "~0.5.0" | ||
"deep-extend": "^0.3.3", | ||
"resolve": "^0.5.0" | ||
}, | ||
@@ -20,0 +21,0 @@ "directories": { |
@@ -1,2 +0,2 @@ | ||
cnf [![Build Status](https://travis-ci.org/e-conomic/config.svg?branch=master)](https://travis-ci.org/e-conomic/config) | ||
cnf [![npm version](https://badge.fury.io/js/cnf.svg)](http://badge.fury.io/js/cnf) [![Build Status](https://travis-ci.org/e-conomic/config.svg?branch=master)](https://travis-ci.org/e-conomic/config) [![Dependency Status](https://david-dm.org/e-conomic/config.svg)](https://david-dm.org/e-conomic/config) [![devDependency Status](https://david-dm.org/e-conomic/config/dev-status.svg)](https://david-dm.org/e-conomic/config#info=devDependencies) | ||
=== | ||
@@ -13,6 +13,6 @@ | ||
console.log('port: '+config.http.port); | ||
console.log('port: ' + config.http.port); | ||
``` | ||
It will look for a configuration file called `$APP_ENV.app.config.js` in the current working directory. | ||
It will look for a configuration file called `$APP_ENV.app.config.js` in the current working directory and will be extended with config from `global.app.config.js`. | ||
@@ -36,2 +36,3 @@ To override configs use a command line argument prefixed with `app.` | ||
--app.mySetting "$regexp(/myRegExp/gmi)" | ||
``` | ||
@@ -5,4 +5,5 @@ var fs = require('fs'); | ||
var env = process.env.APP_ENV || process.env.NODE_ENV || 'development'; | ||
var deepExtend = require('deep-extend'); | ||
var envPath = resolve.sync(env+'.app.config.js', { | ||
var envPath = resolve.sync(env + '.app.config.js', { | ||
basedir: process.cwd(), | ||
@@ -12,8 +13,13 @@ moduleDirectory: 'config' | ||
if (!fs.existsSync(envPath)) { | ||
throw new Error(env+' configuration could not be found'); | ||
} | ||
var envFile = require(envPath); | ||
try { | ||
var globalConfigPath = resolve.sync('global.app.config.js', { | ||
basedir: process.cwd(), | ||
moduleDirectory: 'config' | ||
}); | ||
var globalConfig = require(globalConfigPath); | ||
envFile = deepExtend(globalConfig, envFile); | ||
} catch(e) {} | ||
var replaceConfigs = function(visit) { | ||
@@ -20,0 +26,0 @@ var next = function(prevKeys, obj) { |
Sorry, the diff of this file is not supported yet
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
4217
86
37
2
5
+ Addeddeep-extend@^0.3.3
+ Addeddeep-extend@0.3.3(transitive)
Updatedresolve@^0.5.0