Skip to content

Commit a61d8c9

Browse files
authored
fix: re-add runOnce property to CronJob (#751)
1 parent 1284df4 commit a61d8c9

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/job.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ export class CronJob<OC extends CronOnCompleteCommand | null = null, C = null> {
2121
? CronOnCompleteCallback
2222
: undefined;
2323

24+
get runOnce(): boolean {
25+
return this.cronTime.realDate;
26+
}
27+
2428
private _timeout?: NodeJS.Timeout;
2529
private _callbacks: CronCallback<C, WithOnComplete<OC>>[] = [];
2630

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

257261
// start before calling back so the callbacks have the ability to stop the cron job
258-
if (!this.cronTime.realDate) {
262+
if (!this.runOnce) {
259263
this.start();
260264
}
261265

0 commit comments

Comments
 (0)