Skip to content

Commit

Permalink
fix: re-add runOnce property to CronJob (#751)
Browse files Browse the repository at this point in the history
  • Loading branch information
sheerlox authored Oct 26, 2023
1 parent 1284df4 commit a61d8c9
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/job.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ export class CronJob<OC extends CronOnCompleteCommand | null = null, C = null> {
? CronOnCompleteCallback
: undefined;

get runOnce(): boolean {
return this.cronTime.realDate;
}

private _timeout?: NodeJS.Timeout;
private _callbacks: CronCallback<C, WithOnComplete<OC>>[] = [];

Expand Down Expand Up @@ -255,7 +259,7 @@ export class CronJob<OC extends CronOnCompleteCommand | null = null, C = null> {
this.running = false;

// start before calling back so the callbacks have the ability to stop the cron job
if (!this.cronTime.realDate) {
if (!this.runOnce) {
this.start();
}

Expand Down

0 comments on commit a61d8c9

Please sign in to comment.