Comparing version 1.4.0 to 1.4.1
@@ -92,7 +92,9 @@ (function(root, factory) { | ||
var months = Object.keys(this.month); | ||
var ok = false; | ||
/* if a dayOfMonth is not found in all months, we only need to fix the last | ||
wrong month to prevent infinite loop */ | ||
var lastWrongMonth={}; | ||
for (var i = 0; i < months.length; i++) { | ||
var m = months[i]; | ||
var con = CronTime.monthConstraints[parseInt(m, 10)]; | ||
var ok = false; | ||
var dsom = Object.keys(this.dayOfMonth); | ||
@@ -102,14 +104,25 @@ | ||
var dom = dsom[j]; | ||
if (dom <= con) { | ||
if (dom <= con) | ||
ok = true; | ||
} else { | ||
delete this.dayOfMonth[j]; | ||
this.dayOfMonth[String(Number(dsom[j])) % con] = true; | ||
} | ||
} | ||
if (!ok) { | ||
// save the month inorder to be fixed if all months fails (infinite loop) | ||
lastWrongMonth=m; | ||
console.warn("Month '" + m + "' is limited to '" + con + "' days."); | ||
} | ||
} | ||
// infinit loop detected (dayOfMonth is not found in all months) | ||
if(!ok){ | ||
var con = CronTime.monthConstraints[parseInt(lastWrongMonth, 10)]; | ||
var dsom = Object.keys(this.dayOfMonth); | ||
for (var j = 0; j < dsom.length; j++) { | ||
var dom = dsom[j]; | ||
if(dom > con){ | ||
delete this.dayOfMonth[dom]; | ||
var fixedDay = Number(dom)% con; | ||
this.dayOfMonth[fixedDay] = true; | ||
} | ||
} | ||
} | ||
}, | ||
@@ -116,0 +129,0 @@ |
{ | ||
"name": "cron", | ||
"description": "Cron jobs for your node", | ||
"version": "1.4.0", | ||
"version": "1.4.1", | ||
"author": "Nick Campbell <nicholas.j.campbell@gmail.com> (http://github.com/ncb000gt)", | ||
@@ -6,0 +6,0 @@ "bugs": { |
@@ -899,2 +899,24 @@ var chai = require('chai'); | ||
// from https://github.com/kelektiv/node-cron/issues/180#issuecomment-154108131 | ||
it('should run once not double', function() { | ||
var c = 0; | ||
var d = new Date(2015, 1, 1, 1, 1, 41, 0); | ||
var clock = sinon.useFakeTimers(d.getTime()); | ||
var job = new cron.CronJob({ | ||
cronTime: '* * * * *', | ||
onTick: function() { | ||
c++; | ||
}, | ||
start: true | ||
}); | ||
var minute = 60 * 1000; | ||
clock.tick(minute); | ||
expect(c).to.eql(1); | ||
clock.restore(); | ||
job.stop(); | ||
expect(c).to.eql(1); | ||
}); | ||
it('should run every second monday'); | ||
@@ -901,0 +923,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Deprecated
MaintenanceThe maintainer of the package marked it as deprecated. This could indicate that a single version should not be used, or that the package is no longer maintained and any new vulnerabilities will not be fixed.
Found 1 instance in 1 package
55758
1734
0
2