lore
Version:
Convention-driven framework for building React-Redux applications
40 lines (33 loc) • 1.38 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = getConfig;
var _lodash = require('lodash');
var _lodash2 = _interopRequireDefault(_lodash);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function getDefaultConfig(hooks) {
return _lodash2.default.reduce(hooks, function (result, value, key) {
return _lodash2.default.merge(result, _lodash2.default.result(value, 'defaults'));
}, {});
}
/**
* Generate the final config from the combination of the overrides passed
* into the app, the default config (calculated from the hooks), and the
* user config for the project (loaded and compiled inside this function).
* configOverride takes priority, then the user config, and finally any defaults
* specified the hooks.
*
* @param {Object} configOverride passed into lore.build(configOverride)
*
* @param {Object} hooks Set of hooks that should be loaded
*
* @returns {Object} A reducer function that invokes every reducer inside the
* passed object, and builds a state object with the same shape.
*/
function getConfig(configOverride, hooks, loader) {
var defaultConfig = getDefaultConfig(hooks);
var userConfig = loader.loadUserConfig();
return _lodash2.default.merge({}, defaultConfig, userConfig, configOverride);
}
module.exports = exports['default'];