Skip to content

Commit

Permalink
fix: run once when actual date is given to setTime
Browse files Browse the repository at this point in the history
  • Loading branch information
sheerlox committed Oct 29, 2023
1 parent c16ad6a commit bc83d40
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/job.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,9 +179,13 @@ export class CronJob<OC extends CronOnCompleteCommand | null = null, C = null> {
if (!(time instanceof CronTime)) {
throw new CronError('time must be an instance of CronTime.');
}

const wasRunning = this.running;
this.stop();

this.cronTime = time;
if (time.realDate) this.runOnce = true;

if (wasRunning) this.start();
}

Expand Down

0 comments on commit bc83d40

Please sign in to comment.