Skip to content

Commit

Permalink
Make sure to set lastExecution on runOnInit
Browse files Browse the repository at this point in the history
Signed-off-by: Nick Campbell <nicholas.j.campbell@gmail.com>
  • Loading branch information
ncb000gt committed Aug 4, 2018
1 parent 705e8dd commit ccdb9c2
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions lib/cron.js
Expand Up @@ -395,11 +395,11 @@
function CronJob(cronTime, onTick, onComplete, startNow, timeZone, context, runOnInit, utcOffset) {
var _cronTime = cronTime;
var argCount = 0;
for (var i = 0; i < arguments.length; i++) {
if (arguments[i] !== undefined) {
argCount++
}
}
for (var i = 0; i < arguments.length; i++) {
if (arguments[i] !== undefined) {
argCount++;
}
}
if (typeof cronTime != 'string' && argCount == 1) {
//crontime is an object...
onTick = cronTime.onTick;
Expand All @@ -420,6 +420,7 @@
addCallback.call(this, command2function(onTick));

if (runOnInit) {
this.lastExecution = new Date();
fireOnTick.call(this);
}

Expand Down

0 comments on commit ccdb9c2

Please sign in to comment.