forked from mirrors/probot
Pass fn to proxy method
This commit is contained in:
parent
b8a71dcfdc
commit
f13c96b5a2
|
@ -17,7 +17,7 @@ module.exports = class Workflow {
|
||||||
if (method !== 'constructor') {
|
if (method !== 'constructor') {
|
||||||
// Define a new function in the API for this plugin method, forcing
|
// Define a new function in the API for this plugin method, forcing
|
||||||
// the binding to this to prevent any tampering.
|
// 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);
|
}) && this.filterFn(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
proxy(plugin, method) {
|
proxy(fn) {
|
||||||
return (...args) => {
|
return (...args) => {
|
||||||
// Push new function on the stack that calls the plugin method with a context.
|
// 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 the API to allow methods to be chained.
|
||||||
return this.api;
|
return this.api;
|
||||||
|
|
Loading…
Reference in New Issue