You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
18 lines
668 B
18 lines
668 B
"use strict";
|
|
|
|
import { GenericTask, TaskInfo } from "../types";
|
|
|
|
interface IParameters {
|
|
readonly owner?: string;
|
|
readonly branch?: string;
|
|
readonly task: TaskInfo;
|
|
readonly otherwise?: TaskInfo;
|
|
}
|
|
|
|
export default ((params, processor) => {
|
|
const condition = (!params.owner || params.owner === processor.context.owner)
|
|
&& (!params.branch || params.branch === processor.context.branch || `refs/heads/${params.branch}` === processor.context.branch);
|
|
const task = (condition && params.task) || params.otherwise;
|
|
|
|
return () => processor.processTask(task || { type: "noop", params: {} }, processor.done);
|
|
}) as GenericTask<IParameters>;
|
|
|