config-load
Advanced tools
Comparing version 0.1.0 to 0.1.1
@@ -6,1 +6,5 @@ # Changelog | ||
* Initial release | ||
## 0.1.1 | ||
* `null` selectors |
@@ -33,3 +33,7 @@ // -------------------- | ||
_.forIn(selectors, function(value, name) { | ||
if (config[name] && config[name][value] !== undefined) _.merge(config, config[name][value]); | ||
var selector = config[name]; | ||
if (value !== null) selector = (selector || {})[value]; | ||
if (selector !== undefined) _.merge(config, selector); | ||
delete config[name]; | ||
@@ -36,0 +40,0 @@ }); |
{ | ||
"name": "config-load", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"description": "Load config from a tree of JS/JSON files", | ||
@@ -5,0 +5,0 @@ "main": "./lib/", |
@@ -92,2 +92,29 @@ # config-load.js | ||
##### `null` value | ||
If a `selector`'s value is `null`, it takes the `name` key only. | ||
If config file parsing produces: | ||
```js | ||
{ | ||
url: 'http://example.com/', | ||
local: { | ||
url: 'http://mysite.com/' | ||
} | ||
} | ||
``` | ||
```js | ||
configLoad(path, { selectors: { local: null } } ) | ||
``` | ||
returns: | ||
```js | ||
{ | ||
url: 'http://mysite.com/' | ||
} | ||
``` | ||
## Tests | ||
@@ -94,0 +121,0 @@ |
8130
35
139