Upgrade octokit to v4.1.2

This commit is contained in:
Angela P Wen 2025-02-19 11:13:12 -08:00
parent dbbcbe019d
commit c1745a9831
1214 changed files with 160765 additions and 0 deletions

View file

@ -0,0 +1,37 @@
import { emitterEventNames } from "../generated/webhook-names.js";
function handleEventHandlers(state, webhookName, handler) {
if (!state.hooks[webhookName]) {
state.hooks[webhookName] = [];
}
state.hooks[webhookName].push(handler);
}
function receiverOn(state, webhookNameOrNames, handler) {
if (Array.isArray(webhookNameOrNames)) {
webhookNameOrNames.forEach(
(webhookName) => receiverOn(state, webhookName, handler)
);
return;
}
if (["*", "error"].includes(webhookNameOrNames)) {
const webhookName = webhookNameOrNames === "*" ? "any" : webhookNameOrNames;
const message = `Using the "${webhookNameOrNames}" event with the regular Webhooks.on() function is not supported. Please use the Webhooks.on${webhookName.charAt(0).toUpperCase() + webhookName.slice(1)}() method instead`;
throw new Error(message);
}
if (!emitterEventNames.includes(webhookNameOrNames)) {
state.log.warn(
`"${webhookNameOrNames}" is not a known webhook name (https://developer.github.com/v3/activity/events/types/)`
);
}
handleEventHandlers(state, webhookNameOrNames, handler);
}
function receiverOnAny(state, handler) {
handleEventHandlers(state, "*", handler);
}
function receiverOnError(state, handler) {
handleEventHandlers(state, "error", handler);
}
export {
receiverOn,
receiverOnAny,
receiverOnError
};