Skip to content

Commit

Permalink
Merge pull request #28 from zedtk/master
Browse files Browse the repository at this point in the history
Keep global plugin config
  • Loading branch information
pmowrer committed Nov 3, 2021
2 parents d68fe61 + d2a644c commit ec440ec
Showing 1 changed file with 26 additions and 2 deletions.
28 changes: 26 additions & 2 deletions src/wrapStep.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,24 @@ const wrapStep = (
return Array(10)
.fill(null)
.map((value, index) => {
const wrapperFn = async function(_, context) {
const wrapperFn = async function(globalPluginConfig, context) {
const {
options: { plugins },
} = context;

if (plugins.length <= index) {
context.logger.log(`No more plugins`);
return defaultReturn;
}

const pluginDefinition = plugins[index];
const [pluginName, pluginConfig] = Array.isArray(pluginDefinition)
? pluginDefinition
: [pluginDefinition, {}];

if (!pluginName) {
// Still needed ?
context.logger.log(`Falsy plugin name at index "${index}"`);
return defaultReturn;
} else if (typeof pluginName !== 'string') {
throw new Error(
Expand All @@ -50,10 +58,26 @@ const wrapStep = (
const step = plugin && plugin[stepName];

if (!step) {
context.logger.log(
`Plugin "${pluginName}" does not provide step "${stepName}"`
);
return defaultReturn;
}

return wrapFn(step)(pluginConfig, context);
context.logger.log(
`Start step "${stepName}" of plugin "${pluginName}"`
);
const stepResult = wrapFn(step)(
{ ...globalPluginConfig, ...pluginConfig },
context
);
stepResult.then(() =>
context.logger.log(
`Completed step "${stepName}" of plugin "${pluginName}"`
)
);

return stepResult;
};

Object.defineProperty(wrapperFn, 'name', { value: wrapperName });
Expand Down

0 comments on commit ec440ec

Please sign in to comment.