Comparing version 0.3.1 to 0.4.0
0.4.0 / 2015-03-18 | ||
================== | ||
* Exposes process.env | ||
* Allows variable variables :inception: | ||
* Allows multiple config files per environment. | ||
* Removes singleton. | ||
0.3.1 / 2013-05-07 | ||
@@ -3,0 +12,0 @@ ================== |
@@ -8,2 +8,4 @@ var fs = require('fs'); | ||
var cwd = process.cwd(); | ||
var glob = require('glob'); | ||
var Mustache = require('mustache'); | ||
@@ -17,27 +19,35 @@ var defaults = { | ||
var readConfig = function(configPath, env) { | ||
var f = path.join(configPath, env); | ||
if (exists(f+'.json')) { | ||
return cjson.load(f+'.json'); | ||
} else if (exists(f+'.yaml')) { | ||
return yaml.load(fs.readFileSync(f+'.yaml', 'utf8')); | ||
} | ||
return {}; | ||
var f = path.join(configPath, env); | ||
var obj = {}; | ||
glob.sync(f + '*.{json,yaml}').forEach(function(file) { | ||
if (file.indexOf('.json') !== -1) { | ||
aug(true, obj, cjson.load(file)); | ||
} else { | ||
aug(true, obj, yaml.load(fs.readFileSync(file, 'utf8'))); | ||
} | ||
}); | ||
return obj; | ||
}; | ||
var config = null; | ||
var load = function(options) { | ||
if (!config) { | ||
var opts = aug({}, defaults, options); | ||
var defaultConf = readConfig(opts.path, "default"); | ||
var envConf = readConfig(opts.path, opts.env); | ||
var userConf = {}; | ||
if (opts.userConfig) { | ||
var userConfPath = (typeof opts.userConfig === 'string') ? opts.userConfig : opts.path; | ||
userConf = readConfig(userConfPath, process.env.USER); | ||
} | ||
var config = null; | ||
var opts = aug({}, defaults, options); | ||
config = aug(true, defaultConf, envConf, userConf); | ||
config.env = opts.env; | ||
var defaultConf = readConfig(opts.path, "default"); | ||
var envConf = readConfig(opts.path, opts.env); | ||
var userConf = {}; | ||
if (opts.userConfig) { | ||
var userConfPath = (typeof opts.userConfig === 'string') ? opts.userConfig : opts.path; | ||
userConf = readConfig(userConfPath, process.env.USER); | ||
} | ||
config = aug(true, defaultConf, envConf, userConf); | ||
config.env = opts.env; | ||
config.ENV = process.env || {}; | ||
config = JSON.parse(Mustache.render(JSON.stringify(config), config)); | ||
return config; | ||
@@ -44,0 +54,0 @@ }; |
{ | ||
"name": "confi", | ||
"description": "a simple configuration library", | ||
"version": "0.3.1", | ||
"homepage": "https://github.com/jgallen23/confi", | ||
"author": "Greg Allen <@jgaui> (http://jga.me)", | ||
"version": "0.4.0", | ||
"homepage": "https://github.com/firstandthird/confi", | ||
"author": "First+Third", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/jgallen23/confi.git" | ||
"url": "https://github.com/firstandthird/confi.git" | ||
}, | ||
@@ -14,3 +14,5 @@ "dependencies": { | ||
"cjson": "0.2.1", | ||
"js-yaml": "~2.0.5" | ||
"glob": "^5.0.3", | ||
"js-yaml": "~2.0.5", | ||
"mustache": "^1.1.0" | ||
}, | ||
@@ -17,0 +19,0 @@ "devDependencies": { |
@@ -14,2 +14,3 @@ var confi = require('../'); | ||
exports.testDev = function(t) { | ||
process.env.testEnv = 'test'; | ||
confi.reset(); | ||
@@ -21,2 +22,5 @@ var config = confi.load(); | ||
t.equal(config.analytics.profile, 'ga-xxx'); | ||
t.equal(config.isTest, true); | ||
t.equal(config.testHost, 'localhost/test/path'); | ||
t.equal(config.ENV.testEnv, 'test'); | ||
t.equal(config.env, 'dev'); | ||
@@ -41,3 +45,3 @@ t.done(); | ||
env: 'dev', | ||
userConfig: true | ||
userConfig: true | ||
}); | ||
@@ -44,0 +48,0 @@ t.equal(config.analytics.enabled, true); |
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 2 instances in 1 package
5779
18
153
5
6
+ Addedglob@^5.0.3
+ Addedmustache@^1.1.0
+ Addedbalanced-match@1.0.2(transitive)
+ Addedbrace-expansion@1.1.11(transitive)
+ Addedconcat-map@0.0.1(transitive)
+ Addedglob@5.0.15(transitive)
+ Addedinflight@1.0.6(transitive)
+ Addedinherits@2.0.4(transitive)
+ Addedminimatch@3.1.2(transitive)
+ Addedmustache@1.2.0(transitive)
+ Addedonce@1.4.0(transitive)
+ Addedpath-is-absolute@1.0.1(transitive)
+ Addedwrappy@1.0.2(transitive)