Refactored conditional task; added "otherwise" support

dependabot/npm_and_yarn/BuildServer/eslint-7.2.0
Inga 🏳‍🌈 11 years ago
parent 57b0792e1c
commit 7bca2e50d6
  1. 13
      BuildServer/lib/tasks/conditional.js

@ -1,17 +1,12 @@
"use strict"; "use strict";
module.exports = function (params, processor) { module.exports = function (params, processor) {
var condition = (!params.owner || params.owner === processor.context.owner) && (!params.branch || params.branch === processor.context.branch || "refs/heads/" + params.branch === processor.context.branch),
task = condition ? params.task : params.otherwise;
return { return {
process: function () { process: function () {
if (params.owner && params.owner != processor.context.owner) { return processor.processTask(task || {type: "noop"}, processor.done.bind(processor));
return processor.done();
}
if (params.branch && params.branch != processor.context.branch) {
return processor.done();
}
processor.processTask(params.task, processor.done.bind(processor));
} }
}; };
}; };

Loading…
Cancel
Save