Skip to content
Snippets Groups Projects
Commit 7b4b90c2 authored by Andrew Newdigate's avatar Andrew Newdigate
Browse files

Feature: add `nconf.getBool`

parent 5288214f
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -75,5 +75,27 @@ exports.create = function(configDirectory) {
 
nconf.runtimeEnvironment = nodeEnv;
 
function parseBool(value) {
switch(typeof value) {
case 'boolean':
return value;
case 'number':
return !!value;
case 'string':
return !!JSON.parse(value);
default:
return undefined;
}
}
/**
* Monkey-patch `getBool`
*/
nconf.getBool = function(key) {
var value = this.get(key);
return parseBool(value);
}
return nconf;
};
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment