feat: add job on start option for icons updater (#442)
This commit is contained in:
@@ -2,9 +2,20 @@ import cron from "node-cron";
|
||||
|
||||
import type { MaybePromise } from "@homarr/common/types";
|
||||
|
||||
export const createCronJob = (cronExpression: string) => {
|
||||
interface CreateCronJobOptions {
|
||||
runOnStart?: boolean;
|
||||
}
|
||||
|
||||
export const createCronJob = (
|
||||
cronExpression: string,
|
||||
options: CreateCronJobOptions = { runOnStart: false },
|
||||
) => {
|
||||
return {
|
||||
withCallback: (callback: () => MaybePromise<void>) => {
|
||||
if (options.runOnStart) {
|
||||
void callback();
|
||||
}
|
||||
|
||||
const task = cron.schedule(cronExpression, () => void callback(), {
|
||||
scheduled: false,
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user