fix another edge case

This commit is contained in:
Simon Engledew 2020-12-04 15:18:22 +00:00
parent 1dc40ba165
commit 18c6a7d6d1
No known key found for this signature in database
GPG key ID: 84302E7B02FE8BCE
6 changed files with 38 additions and 8 deletions

9
lib/actions-util.js generated
View file

@ -132,10 +132,13 @@ function branchesToArray(branches) {
if (typeof branches === "string") { if (typeof branches === "string") {
return [branches]; return [branches];
} }
if (!branches || branches.length === 0) { if (Array.isArray(branches)) {
return "**"; if (branches.length === 0) {
return "**";
}
return branches;
} }
return branches; return "**";
} }
var MissingTriggers; var MissingTriggers;
(function (MissingTriggers) { (function (MissingTriggers) {

File diff suppressed because one or more lines are too long

View file

@ -202,6 +202,16 @@ ava_1.default("validateWorkflow() for a range of malformed workflows", (t) => {
t.deepEqual(actionsutil.validateWorkflow(1), [ t.deepEqual(actionsutil.validateWorkflow(1), [
actionsutil.WorkflowErrors.MissingHooks, actionsutil.WorkflowErrors.MissingHooks,
]); ]);
t.deepEqual(actionsutil.validateWorkflow({
on: {
push: {
branches: 1,
},
pull_request: {
branches: 1,
},
},
}), []);
}); });
ava_1.default("validateWorkflow() when on.pull_request for every branch but push specifies branches", (t) => { ava_1.default("validateWorkflow() when on.pull_request for every branch but push specifies branches", (t) => {
const errors = actionsutil.validateWorkflow({ const errors = actionsutil.validateWorkflow({

File diff suppressed because one or more lines are too long

View file

@ -285,6 +285,20 @@ test("validateWorkflow() for a range of malformed workflows", (t) => {
t.deepEqual(actionsutil.validateWorkflow(1 as any), [ t.deepEqual(actionsutil.validateWorkflow(1 as any), [
actionsutil.WorkflowErrors.MissingHooks, actionsutil.WorkflowErrors.MissingHooks,
]); ]);
t.deepEqual(
actionsutil.validateWorkflow({
on: {
push: {
branches: 1,
},
pull_request: {
branches: 1,
},
},
} as any),
[]
);
}); });
test("validateWorkflow() when on.pull_request for every branch but push specifies branches", (t) => { test("validateWorkflow() when on.pull_request for every branch but push specifies branches", (t) => {

View file

@ -168,10 +168,13 @@ function branchesToArray(branches?: string | null | string[]): string[] | "**" {
if (typeof branches === "string") { if (typeof branches === "string") {
return [branches]; return [branches];
} }
if (!branches || branches.length === 0) { if (Array.isArray(branches)) {
return "**"; if (branches.length === 0) {
return "**";
}
return branches;
} }
return branches; return "**";
} }
enum MissingTriggers { enum MissingTriggers {