refactor: build plugin pipeline parameters at initialization

In addition, factorize the pipeline config function to avoid code duplication.
This commit is contained in:
Pierre Vanduynslager
2018-07-10 13:18:58 -04:00
parent eb26254b00
commit 24ce560065
7 changed files with 105 additions and 112 deletions
+1
View File
@@ -42,6 +42,7 @@ module.exports = (type, pluginsPath, globalOpts, pluginOpts, logger) => {
const validator = async input => {
const {outputValidator} = PLUGINS_DEFINITIONS[type] || {};
try {
logger.log('Call plugin "%s"', type);
const result = await func(cloneDeep(input));
if (outputValidator && !outputValidator(result)) {
throw getError(`E${type.toUpperCase()}OUTPUT`, {result, pluginName});