mirror of
https://github.com/marocchino/sticky-pull-request-comment.git
synced 2026-04-06 22:49:25 +00:00
feat: add only_update to exclusive modes validation list
Co-authored-by: marocchino <128431+marocchino@users.noreply.github.com>
This commit is contained in:
parent
da6fd3b3a2
commit
f8ca6e99f5
2 changed files with 6 additions and 6 deletions
|
|
@ -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",
|
||||
)
|
||||
})
|
||||
|
||||
|
|
|
|||
10
src/main.ts
10
src/main.ts
|
|
@ -50,16 +50,16 @@ async function run(): Promise<undefined> {
|
|||
["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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue