mirror of
https://github.com/marocchino/sticky-pull-request-comment.git
synced 2026-04-15 18:45:43 +00:00
fix: add rootDir and types to tsconfig.json to resolve TS5011 build error
Agent-Logs-Url: https://github.com/marocchino/sticky-pull-request-comment/sessions/c726777d-ddec-4ced-8af3-0bafb048ce2f Co-authored-by: marocchino <128431+marocchino@users.noreply.github.com>
This commit is contained in:
parent
6ef1707d4b
commit
c4fbe28317
9 changed files with 546 additions and 0 deletions
22
dist/validate.js
generated
vendored
Normal file
22
dist/validate.js
generated
vendored
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
export function validateBody(body, deleteOldComment, hideOldComment) {
|
||||
if (!deleteOldComment && !hideOldComment && !body) {
|
||||
throw new Error("Either message or path input is required");
|
||||
}
|
||||
}
|
||||
export function validateExclusiveModes(deleteOldComment, recreate, onlyCreateComment, onlyUpdateComment, hideOldComment, hideAndRecreate) {
|
||||
const exclusiveModes = [
|
||||
["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) {
|
||||
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`);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue