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