diff --git a/__tests__/main.test.ts b/__tests__/main.test.ts index ddfdbae..939dbf9 100644 --- a/__tests__/main.test.ts +++ b/__tests__/main.test.ts @@ -142,7 +142,7 @@ describe("run", () => { mockConfig.onlyUpdateComment = true const {core} = await runMain() expect(core.setFailed).toHaveBeenCalledWith( - "only_create and only_update cannot be both set to true", + "only_create and only_update cannot be set to true simultaneously", ) }) diff --git a/src/main.ts b/src/main.ts index aa165a3..37ccdd0 100644 --- a/src/main.ts +++ b/src/main.ts @@ -50,16 +50,16 @@ async function run(): Promise { ["delete", deleteOldComment], ["recreate", recreate], ["only_create", onlyCreateComment], + ["only_update", onlyUpdateComment], ["hide", hideOldComment], ["hide_and_recreate", hideAndRecreate], ] const enabledModes = exclusiveModes.filter(([, flag]) => flag).map(([name]) => name) if (enabledModes.length > 1) { - throw new Error(`${enabledModes.join(" and ")} cannot be set to true simultaneously`) - } - - if (onlyCreateComment && onlyUpdateComment) { - throw new Error("only_create and only_update cannot be both set to true") + const last = enabledModes[enabledModes.length - 1] + const rest = enabledModes.slice(0, -1) + const joined = enabledModes.length === 2 ? `${rest[0]} and ${last}` : `${rest.join(", ")}, and ${last}` + throw new Error(`${joined} cannot be set to true simultaneously`) } const octokit = github.getOctokit(githubToken)