2020-04-29 18:44:27 +03:00
|
|
|
const _ = require('lodash');
|
|
|
|
const defaultConfig = require('./defaults');
|
2021-10-13 10:45:56 +03:00
|
|
|
const allowedKeys = ['posts_per_page', 'image_sizes', 'card_assets'];
|
2017-03-22 09:52:58 +03:00
|
|
|
|
|
|
|
module.exports.create = function configLoader(packageJson) {
|
2020-04-29 18:44:27 +03:00
|
|
|
let config = _.cloneDeep(defaultConfig);
|
2017-03-22 09:52:58 +03:00
|
|
|
|
2019-08-08 11:47:13 +03:00
|
|
|
if (packageJson && Object.prototype.hasOwnProperty.call(packageJson, 'config')) {
|
2017-03-22 09:52:58 +03:00
|
|
|
config = _.assign(config, _.pick(packageJson.config, allowedKeys));
|
|
|
|
}
|
|
|
|
|
|
|
|
return config;
|
|
|
|
};
|