cron 3.0.0-beta.3 → 3.0.0-beta.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +43 -11
- package/lib/time.js +5 -5
- package/package.json +6 -3
- package/types/index.test-d.ts +85 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,35 @@
|
|
|
1
|
+
## [3.0.0-beta.4](https://github.com/kelektiv/node-cron/compare/v3.0.0-beta.3...v3.0.0-beta.4) (2023-09-10)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### 🐛 Bug Fixes
|
|
5
|
+
|
|
6
|
+
* **deps:** update dependency luxon to v3.3.0 & add [@types](https://github.com/types)/luxon ([#689](https://github.com/kelektiv/node-cron/issues/689)) ([c95a449](https://github.com/kelektiv/node-cron/commit/c95a449121e440b82d391fc11f8dc148748f93ec)), closes [#688](https://github.com/kelektiv/node-cron/issues/688)
|
|
7
|
+
* fix range parsing when upper limit = 0 ([#687](https://github.com/kelektiv/node-cron/issues/687)) ([d96746f](https://github.com/kelektiv/node-cron/commit/d96746f7b8f357e565d1fad48c9f70d3d646da64))
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
### 🚨 Tests
|
|
11
|
+
|
|
12
|
+
* add TS types check ([#690](https://github.com/kelektiv/node-cron/issues/690)) ([f046016](https://github.com/kelektiv/node-cron/commit/f046016dc64438c4a12a4615a919b046d3a846de))
|
|
13
|
+
|
|
14
|
+
## [2.4.3](https://github.com/kelektiv/node-cron/compare/v2.4.2...v2.4.3) (2023-08-26)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
### 🐛 Bug Fixes
|
|
18
|
+
|
|
19
|
+
* fix range parsing when upper limit = 0 ([#687](https://github.com/kelektiv/node-cron/issues/687)) ([d96746f](https://github.com/kelektiv/node-cron/commit/d96746f7b8f357e565d1fad48c9f70d3d646da64))
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
### 🚨 Tests
|
|
23
|
+
|
|
24
|
+
* add TS types check ([#690](https://github.com/kelektiv/node-cron/issues/690)) ([f046016](https://github.com/kelektiv/node-cron/commit/f046016dc64438c4a12a4615a919b046d3a846de))
|
|
25
|
+
|
|
26
|
+
## [2.4.2](https://github.com/kelektiv/node-cron/compare/v2.4.1...v2.4.2) (2023-08-26)
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
### 🐛 Bug Fixes
|
|
30
|
+
|
|
31
|
+
* **deps:** update dependency luxon to v3.3.0 & add [@types](https://github.com/types)/luxon ([#689](https://github.com/kelektiv/node-cron/issues/689)) ([c95a449](https://github.com/kelektiv/node-cron/commit/c95a449121e440b82d391fc11f8dc148748f93ec)), closes [#688](https://github.com/kelektiv/node-cron/issues/688)
|
|
32
|
+
|
|
1
33
|
## [3.0.0-beta.3](https://github.com/kelektiv/node-cron/compare/v3.0.0-beta.2...v3.0.0-beta.3) (2023-08-15)
|
|
2
34
|
|
|
3
35
|
|
|
@@ -26,17 +58,6 @@
|
|
|
26
58
|
|
|
27
59
|
* **renovate:** configure renovate ([#683](https://github.com/kelektiv/node-cron/issues/683)) ([9dbe962](https://github.com/kelektiv/node-cron/commit/9dbe962fad1c8b1b020441bce84ab91b1a7b4415))
|
|
28
60
|
|
|
29
|
-
## [3.0.0-beta.1](https://github.com/kelektiv/node-cron/compare/v2.3.1...v3.0.0-beta.1) (2023-07-23)
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
### ⚠ Breaking changes
|
|
33
|
-
|
|
34
|
-
* UNIX standard alignments (#667)
|
|
35
|
-
|
|
36
|
-
### ✨ Features
|
|
37
|
-
|
|
38
|
-
* UNIX standard alignments ([#667](https://github.com/kelektiv/node-cron/issues/667)) ([96ef954](https://github.com/kelektiv/node-cron/commit/96ef954998f9c109cc2a969296568b1b56bbbd79))
|
|
39
|
-
|
|
40
61
|
## [2.4.1](https://github.com/kelektiv/node-cron/compare/v2.4.0...v2.4.1) (2023-08-14)
|
|
41
62
|
|
|
42
63
|
|
|
@@ -84,6 +105,17 @@
|
|
|
84
105
|
* update default branch name ([#678](https://github.com/kelektiv/node-cron/issues/678)) ([7471e95](https://github.com/kelektiv/node-cron/commit/7471e95cb7433b4f29cfa68da0a652ec8cf630b6))
|
|
85
106
|
* wrap setTime tests in describe and move down ([31989e0](https://github.com/kelektiv/node-cron/commit/31989e06f939bf1e9dbc6c0b6fc62c0a7144b9eb))
|
|
86
107
|
|
|
108
|
+
## [3.0.0-beta.1](https://github.com/kelektiv/node-cron/compare/v2.3.1...v3.0.0-beta.1) (2023-07-23)
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
### ⚠ Breaking changes
|
|
112
|
+
|
|
113
|
+
* UNIX standard alignments (#667)
|
|
114
|
+
|
|
115
|
+
### ✨ Features
|
|
116
|
+
|
|
117
|
+
* UNIX standard alignments ([#667](https://github.com/kelektiv/node-cron/issues/667)) ([96ef954](https://github.com/kelektiv/node-cron/commit/96ef954998f9c109cc2a969296568b1b56bbbd79))
|
|
118
|
+
|
|
87
119
|
## [v2.3.1](https://github.com/kelektiv/node-cron/compare/v2.3.0...v2.3.1) (2023-05-25)
|
|
88
120
|
|
|
89
121
|
### Added
|
package/lib/time.js
CHANGED
|
@@ -774,7 +774,7 @@ function CronTime(luxon) {
|
|
|
774
774
|
if (allRanges[i].match(RE_RANGE)) {
|
|
775
775
|
allRanges[i].replace(RE_RANGE, ($0, lower, upper, step) => {
|
|
776
776
|
lower = parseInt(lower, 10);
|
|
777
|
-
upper = parseInt(upper, 10)
|
|
777
|
+
upper = upper !== undefined ? parseInt(upper, 10) : undefined;
|
|
778
778
|
|
|
779
779
|
const wasStepDefined = !isNaN(parseInt(step, 10));
|
|
780
780
|
if (step === '0') {
|
|
@@ -782,14 +782,14 @@ function CronTime(luxon) {
|
|
|
782
782
|
}
|
|
783
783
|
step = parseInt(step, 10) || 1;
|
|
784
784
|
|
|
785
|
-
if (upper && lower > upper) {
|
|
785
|
+
if (upper !== undefined && lower > upper) {
|
|
786
786
|
throw new Error(`Field (${type}) has an invalid range`);
|
|
787
787
|
}
|
|
788
788
|
|
|
789
789
|
const outOfRangeError =
|
|
790
790
|
lower < low ||
|
|
791
|
-
(upper && upper > high) ||
|
|
792
|
-
(
|
|
791
|
+
(upper !== undefined && upper > high) ||
|
|
792
|
+
(upper === undefined && lower > high);
|
|
793
793
|
|
|
794
794
|
if (outOfRangeError) {
|
|
795
795
|
throw new Error(`Field value (${value}) is out of range`);
|
|
@@ -799,7 +799,7 @@ function CronTime(luxon) {
|
|
|
799
799
|
lower = Math.min(Math.max(low, ~~Math.abs(lower)), high);
|
|
800
800
|
|
|
801
801
|
// Positive integer lower than constraints[1]
|
|
802
|
-
if (upper) {
|
|
802
|
+
if (upper !== undefined) {
|
|
803
803
|
upper = Math.min(high, ~~Math.abs(upper));
|
|
804
804
|
} else {
|
|
805
805
|
// If step is provided, the default upper range is the highest value
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cron",
|
|
3
3
|
"description": "Cron jobs for your node",
|
|
4
|
-
"version": "3.0.0-beta.
|
|
4
|
+
"version": "3.0.0-beta.4",
|
|
5
5
|
"author": "Nick Campbell <nicholas.j.campbell@gmail.com> (https://github.com/ncb000gt)",
|
|
6
6
|
"bugs": {
|
|
7
7
|
"url": "https://github.com/kelektiv/node-cron/issues"
|
|
@@ -15,12 +15,14 @@
|
|
|
15
15
|
"lint": "eslint {lib,tests}/*.js",
|
|
16
16
|
"test": "jest --coverage",
|
|
17
17
|
"test:watch": "jest --watch --coverage",
|
|
18
|
+
"test:types": "tsd",
|
|
18
19
|
"prepare": "husky install",
|
|
19
20
|
"release": "semantic-release"
|
|
20
21
|
},
|
|
21
22
|
"types": "types/index.d.ts",
|
|
22
23
|
"dependencies": {
|
|
23
|
-
"luxon": "
|
|
24
|
+
"@types/luxon": "~3.3.0",
|
|
25
|
+
"luxon": "~3.3.0"
|
|
24
26
|
},
|
|
25
27
|
"devDependencies": {
|
|
26
28
|
"@commitlint/cli": "~17.6.6",
|
|
@@ -45,7 +47,8 @@
|
|
|
45
47
|
"jest": "~29.5.x",
|
|
46
48
|
"prettier": "~2.8.x",
|
|
47
49
|
"semantic-release": "~21.0.x",
|
|
48
|
-
"sinon": "^15.0.x"
|
|
50
|
+
"sinon": "^15.0.x",
|
|
51
|
+
"tsd": "^0.28.1"
|
|
49
52
|
},
|
|
50
53
|
"keywords": [
|
|
51
54
|
"cron",
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import * as luxon from 'luxon';
|
|
2
|
+
import { expectType } from 'tsd';
|
|
3
|
+
import * as cron from '..';
|
|
4
|
+
|
|
5
|
+
const CronJob = cron.CronJob;
|
|
6
|
+
const CronTime = cron.CronTime;
|
|
7
|
+
|
|
8
|
+
const DateTime = luxon.DateTime;
|
|
9
|
+
|
|
10
|
+
const timeZone = 'America/Los_Angeles';
|
|
11
|
+
|
|
12
|
+
// basic cron usage
|
|
13
|
+
const job = new CronJob(
|
|
14
|
+
'* * * * * *',
|
|
15
|
+
() => {},
|
|
16
|
+
null,
|
|
17
|
+
true
|
|
18
|
+
);
|
|
19
|
+
|
|
20
|
+
// using factory function with parameters object
|
|
21
|
+
expectType<cron.CronJob>(cron.job({
|
|
22
|
+
cronTime: '00 30 11 * * 1-5',
|
|
23
|
+
onTick: () => {},
|
|
24
|
+
start: false,
|
|
25
|
+
timeZone: 'America/Los_Angeles'
|
|
26
|
+
}));
|
|
27
|
+
|
|
28
|
+
// with timezone
|
|
29
|
+
new CronJob(
|
|
30
|
+
'* * * * * *',
|
|
31
|
+
() => {},
|
|
32
|
+
null,
|
|
33
|
+
true,
|
|
34
|
+
timeZone
|
|
35
|
+
);
|
|
36
|
+
|
|
37
|
+
// with onComplete
|
|
38
|
+
new CronJob(
|
|
39
|
+
'00 30 11 * * 1-5',
|
|
40
|
+
() => {},
|
|
41
|
+
() => {},
|
|
42
|
+
true,
|
|
43
|
+
timeZone
|
|
44
|
+
);
|
|
45
|
+
|
|
46
|
+
// with Date
|
|
47
|
+
new CronJob(
|
|
48
|
+
new Date(),
|
|
49
|
+
() => {},
|
|
50
|
+
null,
|
|
51
|
+
true,
|
|
52
|
+
timeZone
|
|
53
|
+
);
|
|
54
|
+
|
|
55
|
+
// with Luxon DateTime
|
|
56
|
+
new CronJob(
|
|
57
|
+
DateTime.local(),
|
|
58
|
+
() => {},
|
|
59
|
+
null,
|
|
60
|
+
true,
|
|
61
|
+
timeZone
|
|
62
|
+
);
|
|
63
|
+
|
|
64
|
+
// with system commands
|
|
65
|
+
new CronJob(
|
|
66
|
+
'00 30 11 * * 1-5',
|
|
67
|
+
'ls',
|
|
68
|
+
{ command: 'ls', args: ['./'] },
|
|
69
|
+
true,
|
|
70
|
+
timeZone
|
|
71
|
+
);
|
|
72
|
+
|
|
73
|
+
// check function return types
|
|
74
|
+
expectType<Date>(job.lastDate());
|
|
75
|
+
expectType<luxon.DateTime>(job.nextDates());
|
|
76
|
+
expectType<luxon.DateTime | luxon.DateTime[]>(job.nextDates(1));
|
|
77
|
+
expectType<boolean | undefined>(job.running);
|
|
78
|
+
job.setTime(new CronTime('00 30 11 * * 1-2'));
|
|
79
|
+
job.start();
|
|
80
|
+
job.stop();
|
|
81
|
+
|
|
82
|
+
// check cronTime format
|
|
83
|
+
new CronTime('* * * * * *');
|
|
84
|
+
new CronTime(new Date());
|
|
85
|
+
new CronTime(DateTime.local());
|