Comparing version 0.3.3 to 0.4.0
@@ -65,3 +65,4 @@ /* | ||
validate(kids, p, previousErrors); | ||
} else { | ||
} else if (! (typeof p.default === 'undefined' | ||
&& instance[name] === p.default)) { | ||
try { | ||
@@ -318,4 +319,5 @@ p._format(instance[name]); | ||
try { | ||
this.get(path); | ||
return true; | ||
var r = this.get(path); | ||
// values that are set but undefined return false | ||
return typeof r !== 'undefined'; | ||
} catch (e) { | ||
@@ -322,0 +324,0 @@ return false; |
@@ -5,3 +5,3 @@ { | ||
"description": "Unruly configuration management for nodejs", | ||
"version": "0.3.3", | ||
"version": "0.4.0", | ||
"homepage": "https://github.com/lloyd/node-convict", | ||
@@ -8,0 +8,0 @@ "repository": { |
@@ -9,2 +9,7 @@ const should = require('should'); | ||
conf = convict({ | ||
env: { | ||
format: ['bar', 'baz', 'foo'], | ||
default: 'bar', | ||
env: 'NODE_ENV' | ||
}, | ||
foo: { | ||
@@ -43,3 +48,8 @@ bar: 7, | ||
}); | ||
it('should get env', function() { | ||
var val = conf.get('env'); | ||
should.equal(val, 'bar'); | ||
}); | ||
}); | ||
}); |
@@ -6,2 +6,10 @@ const should = require('should'); | ||
var conf; | ||
var conf2 = convict({ | ||
foo: { | ||
none: { | ||
format: String, | ||
default: undefined | ||
} | ||
} | ||
}); | ||
@@ -16,2 +24,18 @@ it('should parse a config specification from a file', function() { | ||
it('should be valid again', function() { | ||
(function() { conf2.validate() }).should.not.throw(); | ||
}); | ||
describe('.has()', function() { | ||
it('should not have undefined properties', function() { | ||
var val = conf.has('foo.bar.madeup'); | ||
should.equal(val, false); | ||
}); | ||
it('should not have properties specified with a default of undefined', function() { | ||
var val = conf.has('foo.none'); | ||
should.equal(val, false); | ||
}); | ||
}); | ||
describe('.get()', function() { | ||
@@ -18,0 +42,0 @@ it('should find a nested value', function() { |
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
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
Copyleft License
License(Experimental) Copyleft license information was found.
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 3 instances in 1 package
Mixed license
License(Experimental) Package contains multiple licenses.
Found 1 instance in 1 package
Non-permissive License
License(Experimental) A license not known to be considered permissive was found.
Found 1 instance in 1 package
0
100
6
35346
40
948