Comparing version 0.2.3 to 0.3.0
@@ -87,3 +87,3 @@ /* | ||
if (typeof o === 'object' && !Array.isArray(o) && typeof o.default === 'undefined') { | ||
if (typeof o === 'object' && !Array.isArray(o) && !('default' in o)) { | ||
props[name] = { | ||
@@ -100,2 +100,3 @@ properties: {}, | ||
if (typeof o === 'object') { | ||
@@ -207,3 +208,3 @@ props[name] = o; | ||
} else { | ||
if (!c[name] && typeof p.default !== 'undefined') c[name] = coerce(name, p.default, schema); | ||
if (!c[name] && 'default' in p) c[name] = coerce(name, p.default, schema); | ||
} | ||
@@ -287,3 +288,3 @@ }); | ||
get: function(path) { | ||
var o = JSON.parse(JSON.stringify(this._instance)); | ||
var o = this._instance; | ||
if (path) { | ||
@@ -293,10 +294,12 @@ var ar = path.split('.'); | ||
var k = ar.shift(); | ||
if (typeof o[k] !== undefined) o = o[k]; | ||
if (o === undefined) break; | ||
if (k in o) { | ||
o = o[k]; | ||
} else { | ||
throw new Error("cannot find configuration param '" + path + "'"); | ||
} | ||
} | ||
} | ||
if (o === undefined) { | ||
throw new Error("cannot find configuration param '" + path + "'"); | ||
} | ||
return o; | ||
return typeof o !== 'undefined' ? | ||
JSON.parse(JSON.stringify(o)) : | ||
void 0; | ||
}, | ||
@@ -303,0 +306,0 @@ has: function(path) { |
@@ -5,3 +5,3 @@ { | ||
"description": "Unruly configuration management for nodejs", | ||
"version": "0.2.3", | ||
"version": "0.3.0", | ||
"homepage": "https://github.com/lloyd/node-convict", | ||
@@ -8,0 +8,0 @@ "repository": { |
@@ -91,2 +91,6 @@ const should = require('should'); | ||
}, | ||
optional: { | ||
format: '*', | ||
default: undefined | ||
} | ||
} | ||
@@ -127,2 +131,7 @@ }); | ||
}); | ||
it('should accept undefined as a default', function() { | ||
var val = conf.get('foo.optional'); | ||
should.equal(val, undefined); | ||
}); | ||
}); |
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
47189
1308