First upload version 0.0.1
This commit is contained in:
33
node_modules/@octokit/webhooks/dist-src/event-handler/validate-event-name.js
generated
vendored
Normal file
33
node_modules/@octokit/webhooks/dist-src/event-handler/validate-event-name.js
generated
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
import { emitterEventNames } from "../generated/webhook-names.js";
|
||||
function validateEventName(eventName, options = {}) {
|
||||
if (typeof eventName !== "string") {
|
||||
throw new TypeError("eventName must be of type string");
|
||||
}
|
||||
if (eventName === "*") {
|
||||
throw new TypeError(
|
||||
`Using the "*" event with the regular Webhooks.on() function is not supported. Please use the Webhooks.onAny() method instead`
|
||||
);
|
||||
}
|
||||
if (eventName === "error") {
|
||||
throw new TypeError(
|
||||
`Using the "error" event with the regular Webhooks.on() function is not supported. Please use the Webhooks.onError() method instead`
|
||||
);
|
||||
}
|
||||
if (options.onUnknownEventName === "ignore") {
|
||||
return;
|
||||
}
|
||||
if (!emitterEventNames.includes(eventName)) {
|
||||
if (options.onUnknownEventName !== "warn") {
|
||||
throw new TypeError(
|
||||
`"${eventName}" is not a known webhook name (https://developer.github.com/v3/activity/events/types/)`
|
||||
);
|
||||
} else {
|
||||
(options.log || console).warn(
|
||||
`"${eventName}" is not a known webhook name (https://developer.github.com/v3/activity/events/types/)`
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
export {
|
||||
validateEventName
|
||||
};
|
||||
Reference in New Issue
Block a user