refactoring and adding capability to recognize more schedules
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
This commit is contained in:
13
server/helper/typeFind.ts
Normal file
13
server/helper/typeFind.ts
Normal file
@ -0,0 +1,13 @@
|
||||
import { scheduleNames, supportedSchedule } from "../types/scheduledEventTypes";
|
||||
|
||||
export function findInScheduleTypes(inputString: string): supportedSchedule {
|
||||
const maybeScheduleName: unknown = JSON.parse(`"${inputString.toLowerCase()}"`);
|
||||
const scheduleName = scheduleNames.find((validName: supportedSchedule) => validName === maybeScheduleName);
|
||||
if (scheduleName) {
|
||||
// `sheepName` comes from the list of `sheepNames` so the compiler is happy.
|
||||
return scheduleName;
|
||||
}
|
||||
throw new Error('That is not a schedule name.');
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user