Socket
Socket
Sign inDemoInstall

nconf

Package Overview
Dependencies
Maintainers
3
Versions
38
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nconf - npm Package Compare versions

Comparing version 0.6.0 to 0.6.1

test/fixtures/scripts/nconf-nested-env.js

23

lib/nconf/stores/env.js

@@ -9,2 +9,3 @@ /*

var util = require('util'),
common = require('../common'),
Memory = require('./memory').Memory;

@@ -21,5 +22,13 @@

this.type = 'env';
this.readOnly = true;
this.options = options || [];
options = options || {};
this.type = 'env';
this.readOnly = true;
this.whitelist = options.whitelist || [];
this.separator = options.separator || '';
if (options instanceof Array) {
this.whitelist = options;
}
if (typeof(options) === 'string') {
this.separator = options;
}
};

@@ -48,5 +57,9 @@

Object.keys(process.env).filter(function (key) {
return !self.options.length || self.options.indexOf(key) !== -1;
return !self.whitelist.length || self.whitelist.indexOf(key) !== -1;
}).forEach(function (key) {
self.set(key, process.env[key]);
if (self.separator) {
self.set(common.key.apply(common, key.split(self.separator)), process.env[key]);
} else {
self.set(key, process.env[key]);
}
});

@@ -53,0 +66,0 @@

@@ -186,3 +186,3 @@ /*

return Object.keys(value).every(function (nested) {
return self.merge(fullKey + ':' + nested, value[nested]);
return self.merge(common.key(fullKey, nested), value[nested]);
});

@@ -211,2 +211,2 @@ };

return this.store || {};
};
};
{
"name": "nconf",
"description": "Hierarchical node.js configuration with files, environment variables, command-line arguments, and atomic object merging.",
"version": "0.6.0",
"version": "0.6.1",
"author": "Nodejitsu Inc. <info@nodejitsu.com>",

@@ -6,0 +6,0 @@ "maintainers": [

@@ -162,2 +162,18 @@ # nconf [![Build Status](https://secure.travis-ci.org/flatiron/nconf.png)](http://travis-ci.org/flatiron/nconf)

nconf.env(['only', 'load', 'these', 'values', 'from', 'process.env']);
//
// Can also specify a separator for nested keys (instead of the default ':')
//
nconf.env('__');
// Get the value of the env variable 'database__host'
var dbHost = nconf.get('database:host');
//
// Or use both options
//
nconf.env({
separator: '__',
whitelist: ['database__host', 'only', 'load', 'these', 'values']
});
var dbHost = nconf.get('database:host');
```

@@ -164,0 +180,0 @@

@@ -63,2 +63,6 @@ /*

env: { SOMETHING: true }
}),
"when 'env' is set to true with a nested separator": helpers.assertSystemConf({
script: path.join(fixturesDir, 'scripts', 'nconf-nested-env.js'),
env: { SOME_THING: 'foobar' }
})

@@ -65,0 +69,0 @@ }

@@ -19,6 +19,7 @@ /*

assert.isFunction(env.loadEnv);
assert.isArray(env.options);
assert.lengthOf(env.options, 0);
assert.isArray(env.whitelist);
assert.lengthOf(env.whitelist, 0);
assert.equal(env.separator, '');
}
}
}).export(module);
}).export(module);
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc