UNPKG

736 BJavaScriptView Raw
1'use strict';
2
3var resolve = require('./resolve')
4 , current = require('./current')
5 ;
6
7function override(prop, overridee, overrider) {
8 var to = overridee[prop]
9 , from = overrider[prop];
10 if (!from) return;
11
12 Object.keys(from).forEach(function (k) {
13 to[k] = from[k];
14 });
15}
16
17// TODO: combining defaults and user config into current config needs tests
18function initializeCurrent(conf) {
19 var structs = [ 'feed', 'inspect' ];
20
21 structs.forEach(function (x) { override(x, current, conf); });
22
23 Object.keys(conf)
24 .filter(function (k) { return !~structs.indexOf(k); })
25 .forEach(function (k) { current[k] = conf[k]; });
26}
27
28module.exports = function () {
29 var config = resolve();
30
31 initializeCurrent(config);
32};