Comparing version 0.0.7 to 0.0.8
{ | ||
"name": "configya", | ||
"version": "0.0.7", | ||
"version": "0.0.8", | ||
"description": "Config files that defer to env settings.", | ||
@@ -17,5 +17,4 @@ "main": "src/configya.js", | ||
"dependencies": { | ||
"gnosis": "^0.3.0", | ||
"lodash": "^2.4.1" | ||
} | ||
} |
@@ -36,3 +36,2 @@ require( 'should' ); | ||
{ nested: { key: 'imma default!' }, another: { key: 'hiya' } } ); | ||
it( 'should prefer file value over default', function() { | ||
@@ -231,25 +230,38 @@ cfg.nested.key.should.equal( 'a test of nested keys from files' ); | ||
before( function() { | ||
process.env[ 'test_redis_port' ] = 6379; | ||
process.env[ 'test_riak_port' ] = 8087; | ||
cfg = require( '../src/configya.js' )( | ||
{ | ||
redis: { address: '127.0.0.1', port: 1234 }, | ||
riak: { address: 'riak1', port: 5678 } | ||
test: { | ||
redis: { address: '127.0.0.1', port: 1234 }, | ||
riak: { address: 'riak1', port: 5678 } | ||
} | ||
} ); | ||
process.env[ 'REDIS_PORT' ] = 6379; | ||
process.env[ 'RIAK_PORT' ] = 8087; | ||
} ); | ||
it( 'should keep environment ports seperate', function() { | ||
cfg.riak.port.should.equal( '8087' ); | ||
cfg.redis.port.should.equal( '6379' ); | ||
cfg.test.riak.port.should.equal( '8087' ); | ||
cfg.test.redis.port.should.equal( '6379' ); | ||
} ); | ||
it( 'should keep default addresses seperate', function() { | ||
cfg.redis.address.should.equal( '127.0.0.1' ); | ||
cfg.riak.address.should.equal( 'riak1' ); | ||
cfg.test.riak.address.should.equal( 'riak1' ); | ||
cfg.test.redis.address.should.equal( '127.0.0.1' ); | ||
} ); | ||
} ); | ||
describe( 'with child property matching root property', function() { | ||
var cfg; | ||
before( function() { | ||
cfg = require( '../src/configya.js' )( { 'test-key': 'root key value', child: { 'test-key': 'child key value' } } ); | ||
} ); | ||
it( 'should not overwrite root property', function() { | ||
cfg[ 'test-key' ].should.equal( 'root key value' ); | ||
} ); | ||
} ) | ||
after( function() { | ||
delete process.env[ 'redis_port' ]; | ||
delete process.env[ 'riak_port' ]; | ||
delete process.env[ 'test_redis_port' ]; | ||
delete process.env[ 'test_riak_port' ]; | ||
delete process.env[ 'missing_from_config' ]; | ||
@@ -256,0 +268,0 @@ delete process.env[ 'deploy-type' ]; |
var fs = require( 'fs' ); | ||
var path = require( 'path' ); | ||
var gnosis = require( 'gnosis' )(); | ||
var _ = require( 'lodash' ); | ||
@@ -20,8 +19,8 @@ | ||
var key = paths.shift(); | ||
k = key.toLowerCase(); | ||
if ( paths.length === 0 ) { | ||
target[ key ] = val; | ||
target[ k ] = val; | ||
} else { | ||
var child = target[ key ] || {}; | ||
target[ key ] = child; | ||
target[ k ] = child; | ||
ensurePath( child, val, paths ); | ||
@@ -31,15 +30,17 @@ } | ||
function parseIntoTarget( source, target, original ) { | ||
var undRegx = /^[_]+/; | ||
gnosis.traverse( source, function( instance, key, val, meta, root ) { | ||
var k = key.toLowerCase(); | ||
function parseIntoTarget( source, target, cache ) { | ||
var preRgx = /^[_]*/, | ||
postRgx = /[_]*$/; | ||
_.each( source, function( val, key ) { | ||
var k = key.toLowerCase(), | ||
scrubbed = key.replace( preRgx, '' ).replace( postRgx, '' ), | ||
paths = scrubbed.split( '_' ); | ||
target[ key ] = val; | ||
target[ k ] = val; | ||
target[ key ] = val; | ||
if( original ) { | ||
target[ original ][ key ] = val; | ||
ensurePath( target, val, paths ); | ||
if( cache ) { | ||
target[ cache ][ key ] = val; | ||
target[ cache ][ k ] = val; | ||
} | ||
var paths = undRegx.test( key ) ? [ k ] : k.split( "_" ); | ||
ensurePath( target, val, paths ); | ||
} ); | ||
return target; | ||
} | ||
@@ -46,0 +47,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 4 instances in 1 package
14353
1
305
8
- Removedgnosis@^0.3.0
- Removedgnosis@0.3.0(transitive)