diff --git a/lib/workflow.js b/lib/workflow.js index 49930612..876f6bf6 100644 --- a/lib/workflow.js +++ b/lib/workflow.js @@ -17,7 +17,7 @@ module.exports = class Workflow { if (method !== 'constructor') { // Define a new function in the API for this plugin method, forcing // the binding to this to prevent any tampering. - this.api[method] = this.proxy(plugin, method).bind(this); + this.api[method] = this.proxy(plugin[method]).bind(this); } } } @@ -37,10 +37,10 @@ module.exports = class Workflow { }) && this.filterFn(event); } - proxy(plugin, method) { + proxy(fn) { return (...args) => { // Push new function on the stack that calls the plugin method with a context. - this.stack.push(context => plugin[method](context, ...args)); + this.stack.push(context => fn(context, ...args)); // Return the API to allow methods to be chained. return this.api;