fix: Use default plugin if the path property is missing from a single plugin configuration

This commit is contained in:
Pierre Vanduynslager
2017-11-22 19:47:09 -05:00
parent facdadaddb
commit d4c7605f68
3 changed files with 31 additions and 14 deletions
+5 -1
View File
@@ -1,4 +1,4 @@
const {isArray} = require('lodash');
const {isArray, isObject} = require('lodash');
const DEFINITIONS = require('./definitions');
const pipeline = require('./pipeline');
const normalize = require('./normalize');
@@ -8,6 +8,10 @@ module.exports = (options, logger) =>
const {config, output, default: def} = DEFINITIONS[pluginType];
let pluginConfs;
if (options[pluginType]) {
// If an object is passed and the path is missing, set the default one for single plugins
if (isObject(options[pluginType]) && !options[pluginType].path && !isArray(def)) {
options[pluginType].path = def;
}
if (config && !config.validator(options[pluginType])) {
throw new Error(config.message);
}