mirror of
https://github.com/zhigang1992/probot.git
synced 2026-06-17 23:15:30 +08:00
42 lines
838 B
JavaScript
42 lines
838 B
JavaScript
const issues = require('./plugins/issues');
|
|
|
|
class WorkflowCore {
|
|
constructor(events) {
|
|
this.events = events;
|
|
this.filterFn = () => true;
|
|
}
|
|
|
|
filter(fn) {
|
|
this.filterFn = fn;
|
|
return this;
|
|
}
|
|
|
|
matchesEvent(event) {
|
|
const eventWithAction = [event.event, event.payload.action];
|
|
|
|
return this.events.find(e => {
|
|
const parts = e.split('.');
|
|
for (let i = 0; i < parts.length; i++) {
|
|
if (parts[i] !== eventWithAction[i]) {
|
|
return false;
|
|
}
|
|
}
|
|
return true;
|
|
});
|
|
}
|
|
}
|
|
|
|
// FIXME: issues
|
|
const plugins = [
|
|
issues.Plugin
|
|
];
|
|
|
|
// Helper to combine an array of mixins into one class
|
|
function mix(superclass, ...mixins) {
|
|
return mixins.reduce((c, mixin) => mixin(c), superclass);
|
|
}
|
|
|
|
class Workflow extends mix(WorkflowCore, ...plugins) {}
|
|
|
|
module.exports = Workflow;
|