cron 2.3.0 → 2.3.1
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/README.md +22 -14
- package/lib/cron.js +2 -2
- package/lib/job.js +19 -18
- package/lib/time.js +39 -39
- package/package.json +22 -16
- package/.editorconfig +0 -5
- package/.eslintrc +0 -26
- package/.github/ISSUE_TEMPLATE/bug_issue.yaml +0 -26
- package/.github/ISSUE_TEMPLATE/feature.yaml +0 -31
- package/.github/workflows/nodejs.yml +0 -39
- package/.prettierrc +0 -7
- package/bower.json +0 -29
- package/examples/at_10_minutes.js +0 -9
- package/examples/at_midnight.js +0 -9
- package/examples/basic.js +0 -9
- package/examples/complex_expr.js +0 -9
- package/examples/every_10_minutes.js +0 -9
- package/examples/every_30_minutes_between_9_and_5.js +0 -9
- package/examples/get_next_runs.js +0 -24
- package/examples/in_the_past.js +0 -19
- package/examples/is_crontime_valid.js +0 -9
- package/examples/is_job_running.js +0 -10
- package/examples/long_running_on_tick.js +0 -20
- package/examples/mon_to_fri_at_11_30.js +0 -9
- package/examples/multiple_jobs.js +0 -15
- package/examples/object_param.js +0 -23
- package/examples/run_at_specific_date.js +0 -11
- package/examples/time_dom_syntax_with_tz.js +0 -13
- package/examples/utc_offset_syntax.js +0 -16
- package/tests/cron.test.js +0 -937
- package/tests/crontime.test.js +0 -648
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
<p align="center">
|
|
2
|
+
<img src="logo.svg" alt="Node Cron Alarm Clock Star Logo" width="100" />
|
|
3
|
+
</p>
|
|
4
4
|
|
|
5
5
|
# node-cron
|
|
6
6
|
|
|
@@ -14,7 +14,12 @@ This project is looking for help! If you're interested in helping with the proje
|
|
|
14
14
|
[](https://badgen.net/bundlephobia/minzip/cron)
|
|
15
15
|
[](https://badgen.net/npm/dm/cron)
|
|
16
16
|
|
|
17
|
-
Cron is a tool that allows you to execute _something_ on a schedule. This is typically done using the cron syntax. We allow you to
|
|
17
|
+
Cron is a tool that allows you to execute _something_ on a schedule. This is typically done using the cron syntax. We allow you to:
|
|
18
|
+
|
|
19
|
+
- execute a function whenever your scheduled job triggers
|
|
20
|
+
- execute a job external to the javascript process using `child_process`
|
|
21
|
+
- use a Date object instead of cron syntax as the trigger for your callback
|
|
22
|
+
- use an additional slot for seconds (leaving it off will default to 0 and match the Unix behavior)
|
|
18
23
|
|
|
19
24
|
## Installation
|
|
20
25
|
|
|
@@ -22,11 +27,11 @@ Cron is a tool that allows you to execute _something_ on a schedule. This is typ
|
|
|
22
27
|
npm install cron
|
|
23
28
|
```
|
|
24
29
|
|
|
25
|
-
## Versions and Backwards compatibility breaks
|
|
30
|
+
## Versions and Backwards compatibility breaks
|
|
26
31
|
|
|
27
|
-
As goes with semver, breaking backwards compatibility should be explicit in the versioning of your library. As such, we'll upgrade the version of this module in accordance with breaking changes (
|
|
32
|
+
As goes with semver, breaking backwards compatibility should be explicit in the versioning of your library. As such, we'll upgrade the version of this module in accordance with breaking changes (We're not always great about doing it this way so if you notice that there are breaking changes that haven't been bumped appropriately please let us know).
|
|
28
33
|
|
|
29
|
-
## Usage (basic cron usage)
|
|
34
|
+
## Usage (basic cron usage)
|
|
30
35
|
|
|
31
36
|
```javascript
|
|
32
37
|
var CronJob = require('cron').CronJob;
|
|
@@ -39,15 +44,14 @@ var job = new CronJob(
|
|
|
39
44
|
true,
|
|
40
45
|
'America/Los_Angeles'
|
|
41
46
|
);
|
|
42
|
-
//
|
|
43
|
-
// job.start()
|
|
47
|
+
// job.start() - See note below when to use this
|
|
44
48
|
```
|
|
45
49
|
|
|
46
|
-
Note -
|
|
50
|
+
Note - In the example above, the 4th parameter of `CronJob()` automatically starts the job on initialization. If this parameter is falsy or not provided, the job needs to be explicitly started using `job.start()`.
|
|
47
51
|
|
|
48
52
|
There are more examples available in this repository at: [/examples](https://github.com/kelektiv/node-cron/tree/master/examples)
|
|
49
53
|
|
|
50
|
-
## Available Cron patterns
|
|
54
|
+
## Available Cron patterns
|
|
51
55
|
|
|
52
56
|
```
|
|
53
57
|
Asterisks e.g. *
|
|
@@ -72,7 +76,7 @@ When specifying your cron values you'll need to make sure that your values fall
|
|
|
72
76
|
|
|
73
77
|
## Gotchas
|
|
74
78
|
|
|
75
|
-
- Millisecond level granularity in JS `Date` or Luxon `DateTime` objects: Because computers take time to do things, there may be some delay in execution. This should be on the order of milliseconds. This module doesn't allow MS level granularity for the regular cron syntax, but _does_ allow you to specify a real date of execution in either a javascript `Date` object or a Luxon `DateTime` object. When this happens you may find that you aren't able to execute a job that _should_ run in the future like with `new Date().setMilliseconds(new Date().getMilliseconds() + 1)`. This is due to those cycles of execution above. This wont be the same for everyone because of compute speed. When
|
|
79
|
+
- Millisecond level granularity in JS `Date` or Luxon `DateTime` objects: Because computers take time to do things, there may be some delay in execution. This should be on the order of milliseconds. This module doesn't allow MS level granularity for the regular cron syntax, but _does_ allow you to specify a real date of execution in either a javascript `Date` object or a Luxon `DateTime` object. When this happens you may find that you aren't able to execute a job that _should_ run in the future like with `new Date().setMilliseconds(new Date().getMilliseconds() + 1)`. This is due to those cycles of execution above. This wont be the same for everyone because of compute speed. When we tried it locally we saw that somewhere around the 4-5 ms mark was where we got consistent ticks using real dates, but anything less than that would result in an exception. This could be really confusing. We could restrict the granularity for all dates to seconds, but felt that it wasn't a huge problem so long as you were made aware. If this becomes more of an issue, We can revisit it.
|
|
76
80
|
- Arrow Functions for `onTick`: Arrow functions get their `this` context from their parent scope. Thus, if you use them, you will not get the `this` context of the cronjob. You can read a little more in issue [GH-47](https://github.com/kelektiv/node-cron/issues/47#issuecomment-459762775)
|
|
77
81
|
|
|
78
82
|
## API
|
|
@@ -111,6 +115,10 @@ Join the [Discord server](https://discord.gg/yyKns29zch)! Here you can discuss i
|
|
|
111
115
|
|
|
112
116
|
## Contributing
|
|
113
117
|
|
|
118
|
+
### Looking for maintainers/contributors
|
|
119
|
+
|
|
120
|
+
This project is looking for help! If you're interested in helping with the project please reach out to me (ncb000gt) on [Twitter](https://twitter.com/ncb000gt). We'd love for it to continue on, but it needs a lot of attention. You can also join the [Discord server](https://discord.gg/yyKns29zch) to learn more about what needs to be done.
|
|
121
|
+
|
|
114
122
|
### Submitting Bugs/Issues
|
|
115
123
|
|
|
116
124
|
Before submitting a bug, please search the existing issues, [Discord](https://discord.gg/yyKns29zch) conversations, and the web to see if someone else has run into the same issue before.
|
|
@@ -119,8 +127,8 @@ Because we can't magically know what you are doing to expose an issue, it is bes
|
|
|
119
127
|
|
|
120
128
|
### Acknowledgements
|
|
121
129
|
|
|
122
|
-
This is a community effort project. In the truest sense, this project started as an open source project from [cron.js](http://github.com/padolsey/cron.js) and grew into something else. Other people have contributed code, time, and oversight to the project. At this point there are too many to name here so
|
|
130
|
+
This is a community effort project. In the truest sense, this project started as an open source project from [cron.js](http://github.com/padolsey/cron.js) and grew into something else. Other people have contributed code, time, and oversight to the project. At this point there are too many to name here so We'll just say thanks.
|
|
123
131
|
|
|
124
132
|
## License
|
|
125
133
|
|
|
126
|
-
MIT
|
|
134
|
+
MIT
|
package/lib/cron.js
CHANGED
|
@@ -7,8 +7,8 @@
|
|
|
7
7
|
root.Cron = factory(root.luxon);
|
|
8
8
|
}
|
|
9
9
|
})(this, function (luxon, childProcess) {
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
const exports = {};
|
|
11
|
+
const spawn = childProcess && childProcess.spawn;
|
|
12
12
|
const CronTime = require('./time')(luxon);
|
|
13
13
|
const CronJob = require('./job')(CronTime, spawn);
|
|
14
14
|
|
package/lib/job.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
function CronJob(CronTime, spawn) {
|
|
2
2
|
function fnWrap(cmd) {
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
let command;
|
|
4
|
+
let args;
|
|
5
5
|
|
|
6
6
|
switch (typeof cmd) {
|
|
7
7
|
case 'string':
|
|
@@ -14,7 +14,7 @@ function CronJob(CronTime, spawn) {
|
|
|
14
14
|
command = cmd && cmd.command;
|
|
15
15
|
if (command) {
|
|
16
16
|
args = cmd.args;
|
|
17
|
-
|
|
17
|
+
const options = cmd.options;
|
|
18
18
|
|
|
19
19
|
return spawn.bind(undefined, command, args, options);
|
|
20
20
|
}
|
|
@@ -35,9 +35,9 @@ function CronJob(CronTime, spawn) {
|
|
|
35
35
|
utcOffset,
|
|
36
36
|
unrefTimeout
|
|
37
37
|
) {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
for (
|
|
38
|
+
let _cronTime = cronTime;
|
|
39
|
+
let argCount = 0;
|
|
40
|
+
for (let i = 0; i < arguments.length; i++) {
|
|
41
41
|
if (arguments[i] !== undefined) {
|
|
42
42
|
argCount++;
|
|
43
43
|
}
|
|
@@ -76,7 +76,7 @@ function CronJob(CronTime, spawn) {
|
|
|
76
76
|
return this;
|
|
77
77
|
}
|
|
78
78
|
|
|
79
|
-
|
|
79
|
+
const addCallback = function (callback) {
|
|
80
80
|
if (typeof callback === 'function') {
|
|
81
81
|
this._callbacks.push(callback);
|
|
82
82
|
}
|
|
@@ -88,17 +88,18 @@ function CronJob(CronTime, spawn) {
|
|
|
88
88
|
// crontime is an object...
|
|
89
89
|
throw new Error('time must be an instance of CronTime.');
|
|
90
90
|
}
|
|
91
|
+
const wasRunning = this.running;
|
|
91
92
|
this.stop();
|
|
92
93
|
this.cronTime = time;
|
|
93
|
-
this.start();
|
|
94
|
+
if (wasRunning) this.start();
|
|
94
95
|
};
|
|
95
96
|
|
|
96
97
|
CJ.prototype.nextDate = function () {
|
|
97
98
|
return this.cronTime.sendAt();
|
|
98
99
|
};
|
|
99
100
|
|
|
100
|
-
|
|
101
|
-
for (
|
|
101
|
+
const fireOnTick = function () {
|
|
102
|
+
for (let i = this._callbacks.length - 1; i >= 0; i--) {
|
|
102
103
|
this._callbacks[i].call(this.context, this.onComplete);
|
|
103
104
|
}
|
|
104
105
|
};
|
|
@@ -108,16 +109,16 @@ function CronJob(CronTime, spawn) {
|
|
|
108
109
|
return this.cronTime.sendAt(i);
|
|
109
110
|
};
|
|
110
111
|
|
|
111
|
-
|
|
112
|
+
const start = function () {
|
|
112
113
|
if (this.running) {
|
|
113
114
|
return;
|
|
114
115
|
}
|
|
115
116
|
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
117
|
+
const MAXDELAY = 2147483647; // The maximum number of milliseconds setTimeout will wait.
|
|
118
|
+
const self = this;
|
|
119
|
+
let timeout = this.cronTime.getTimeout();
|
|
120
|
+
let remaining = 0;
|
|
121
|
+
let startTime;
|
|
121
122
|
|
|
122
123
|
if (this.cronTime.realDate) {
|
|
123
124
|
this.runOnce = true;
|
|
@@ -134,10 +135,10 @@ function CronJob(CronTime, spawn) {
|
|
|
134
135
|
// The callback wrapper checks if it needs to sleep another period or not
|
|
135
136
|
// and does the real callback logic when it's time.
|
|
136
137
|
function callbackWrapper() {
|
|
137
|
-
|
|
138
|
+
const diff = startTime + timeout - Date.now();
|
|
138
139
|
|
|
139
140
|
if (diff > 0) {
|
|
140
|
-
|
|
141
|
+
let newTimeout = self.cronTime.getTimeout();
|
|
141
142
|
|
|
142
143
|
if (newTimeout > diff) {
|
|
143
144
|
newTimeout = diff;
|
package/lib/time.js
CHANGED
|
@@ -70,7 +70,7 @@ function CronTime(luxon) {
|
|
|
70
70
|
this.source = source;
|
|
71
71
|
|
|
72
72
|
if (zone) {
|
|
73
|
-
const dt = luxon.DateTime.fromObject({}, { zone
|
|
73
|
+
const dt = luxon.DateTime.fromObject({}, { zone });
|
|
74
74
|
if (dt.invalid) {
|
|
75
75
|
throw new Error('Invalid timezone.');
|
|
76
76
|
}
|
|
@@ -82,8 +82,8 @@ function CronTime(luxon) {
|
|
|
82
82
|
this.utcOffset = utcOffset;
|
|
83
83
|
}
|
|
84
84
|
|
|
85
|
-
|
|
86
|
-
TIME_UNITS.
|
|
85
|
+
const that = this;
|
|
86
|
+
TIME_UNITS.forEach(timeUnit => {
|
|
87
87
|
that[timeUnit] = {};
|
|
88
88
|
});
|
|
89
89
|
|
|
@@ -103,19 +103,19 @@ function CronTime(luxon) {
|
|
|
103
103
|
* Ensure that the syntax parsed correctly and correct the specified values if needed.
|
|
104
104
|
*/
|
|
105
105
|
_verifyParse: function () {
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
106
|
+
const months = Object.keys(this.month);
|
|
107
|
+
const dom = Object.keys(this.dayOfMonth);
|
|
108
|
+
let ok = false;
|
|
109
109
|
|
|
110
110
|
/* if a dayOfMonth is not found in all months, we only need to fix the last
|
|
111
111
|
wrong month to prevent infinite loop */
|
|
112
|
-
|
|
113
|
-
for (
|
|
114
|
-
|
|
115
|
-
|
|
112
|
+
let lastWrongMonth = NaN;
|
|
113
|
+
for (let i = 0; i < months.length; i++) {
|
|
114
|
+
const m = months[i];
|
|
115
|
+
const con = MONTH_CONSTRAINTS[parseInt(m, 10)];
|
|
116
116
|
|
|
117
|
-
for (
|
|
118
|
-
|
|
117
|
+
for (let j = 0; j < dom.length; j++) {
|
|
118
|
+
const day = dom[j];
|
|
119
119
|
if (day <= con) {
|
|
120
120
|
ok = true;
|
|
121
121
|
}
|
|
@@ -130,12 +130,12 @@ function CronTime(luxon) {
|
|
|
130
130
|
|
|
131
131
|
// infinite loop detected (dayOfMonth is not found in all months)
|
|
132
132
|
if (!ok) {
|
|
133
|
-
|
|
134
|
-
for (
|
|
135
|
-
|
|
133
|
+
const notOkCon = MONTH_CONSTRAINTS[parseInt(lastWrongMonth, 10)];
|
|
134
|
+
for (let k = 0; k < dom.length; k++) {
|
|
135
|
+
const notOkDay = dom[k];
|
|
136
136
|
if (notOkDay > notOkCon) {
|
|
137
137
|
delete this.dayOfMonth[notOkDay];
|
|
138
|
-
|
|
138
|
+
const fixedDay = Number(notOkDay) % notOkCon;
|
|
139
139
|
this.dayOfMonth[fixedDay] = true;
|
|
140
140
|
}
|
|
141
141
|
}
|
|
@@ -146,7 +146,7 @@ function CronTime(luxon) {
|
|
|
146
146
|
* Calculate the "next" scheduled time
|
|
147
147
|
*/
|
|
148
148
|
sendAt: function (i) {
|
|
149
|
-
|
|
149
|
+
let date = this.realDate ? this.source : luxon.DateTime.local();
|
|
150
150
|
if (this.zone) {
|
|
151
151
|
date = date.setZone(this.zone);
|
|
152
152
|
}
|
|
@@ -185,7 +185,7 @@ function CronTime(luxon) {
|
|
|
185
185
|
return this._getNextDateFrom(date);
|
|
186
186
|
} else {
|
|
187
187
|
// return the next schedule times
|
|
188
|
-
|
|
188
|
+
const dates = [];
|
|
189
189
|
for (; i > 0; i--) {
|
|
190
190
|
date = this._getNextDateFrom(date);
|
|
191
191
|
dates.push(date);
|
|
@@ -213,7 +213,7 @@ function CronTime(luxon) {
|
|
|
213
213
|
* Json representation of the parsed cron syntax.
|
|
214
214
|
*/
|
|
215
215
|
toJSON: function () {
|
|
216
|
-
|
|
216
|
+
const self = this;
|
|
217
217
|
return TIME_UNITS.map(function (timeName) {
|
|
218
218
|
return self._wcOrAll(timeName);
|
|
219
219
|
});
|
|
@@ -244,8 +244,8 @@ function CronTime(luxon) {
|
|
|
244
244
|
if (start instanceof Date) {
|
|
245
245
|
start = luxon.DateTime.fromJSDate(start);
|
|
246
246
|
}
|
|
247
|
-
|
|
248
|
-
|
|
247
|
+
let date = start;
|
|
248
|
+
const firstDate = start.toMillis();
|
|
249
249
|
if (zone) {
|
|
250
250
|
date = date.setZone(zone);
|
|
251
251
|
}
|
|
@@ -262,10 +262,10 @@ function CronTime(luxon) {
|
|
|
262
262
|
// it shouldn't take more than 5 seconds to find the next execution time
|
|
263
263
|
// being very generous with this. Throw error if it takes too long to find the next time to protect from
|
|
264
264
|
// infinite loop.
|
|
265
|
-
|
|
265
|
+
const timeout = Date.now() + 5000;
|
|
266
266
|
// determine next date
|
|
267
267
|
while (true) {
|
|
268
|
-
|
|
268
|
+
const diff = date - start;
|
|
269
269
|
|
|
270
270
|
// hard stop if the current date is after the expected execution
|
|
271
271
|
if (Date.now() > timeout) {
|
|
@@ -661,8 +661,8 @@ function CronTime(luxon) {
|
|
|
661
661
|
return '*';
|
|
662
662
|
}
|
|
663
663
|
|
|
664
|
-
|
|
665
|
-
for (
|
|
664
|
+
const all = [];
|
|
665
|
+
for (const time in this[type]) {
|
|
666
666
|
all.push(time);
|
|
667
667
|
}
|
|
668
668
|
|
|
@@ -670,9 +670,9 @@ function CronTime(luxon) {
|
|
|
670
670
|
},
|
|
671
671
|
|
|
672
672
|
_hasAll: function (type) {
|
|
673
|
-
|
|
673
|
+
const constraints = CONSTRAINTS[TIME_UNITS.indexOf(type)];
|
|
674
674
|
|
|
675
|
-
for (
|
|
675
|
+
for (let i = constraints[0], n = constraints[1]; i < n; i++) {
|
|
676
676
|
if (!(i in this[type])) {
|
|
677
677
|
return false;
|
|
678
678
|
}
|
|
@@ -707,7 +707,7 @@ function CronTime(luxon) {
|
|
|
707
707
|
throw new Error(`Unknown alias: ${alias}`);
|
|
708
708
|
});
|
|
709
709
|
|
|
710
|
-
|
|
710
|
+
const units = source.trim().split(/\s+/);
|
|
711
711
|
|
|
712
712
|
// seconds are optional
|
|
713
713
|
if (units.length < TIME_UNITS_LEN - 1) {
|
|
@@ -718,12 +718,12 @@ function CronTime(luxon) {
|
|
|
718
718
|
throw new Error('Too many fields');
|
|
719
719
|
}
|
|
720
720
|
|
|
721
|
-
|
|
722
|
-
for (
|
|
721
|
+
const unitsLen = units.length;
|
|
722
|
+
for (let i = 0; i < TIME_UNITS_LEN; i++) {
|
|
723
723
|
// If the split source string doesn't contain all digits,
|
|
724
724
|
// assume defaults for first n missing digits.
|
|
725
725
|
// This adds support for 5-digit standard cron syntax
|
|
726
|
-
|
|
726
|
+
const cur = units[i - (TIME_UNITS_LEN - unitsLen)] || PARSE_DEFAULTS[i];
|
|
727
727
|
this._parseField(cur, TIME_UNITS[i], CONSTRAINTS[i]);
|
|
728
728
|
}
|
|
729
729
|
},
|
|
@@ -739,14 +739,14 @@ function CronTime(luxon) {
|
|
|
739
739
|
* - Starting with the lower bounds of the range iterate by step up to the upper bounds and toggle the CronTime field value flag on.
|
|
740
740
|
*/
|
|
741
741
|
_parseField: function (value, type, constraints) {
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
742
|
+
const typeObj = this[type];
|
|
743
|
+
let pointer;
|
|
744
|
+
const low = constraints[0];
|
|
745
|
+
const high = constraints[1];
|
|
746
746
|
|
|
747
|
-
|
|
747
|
+
const fields = value.split(',');
|
|
748
748
|
fields.forEach(field => {
|
|
749
|
-
|
|
749
|
+
const wildcardIndex = field.indexOf('*');
|
|
750
750
|
if (wildcardIndex !== -1 && wildcardIndex !== 0) {
|
|
751
751
|
throw new Error(
|
|
752
752
|
`Field (${field}) has an invalid wildcard expression`
|
|
@@ -758,9 +758,9 @@ function CronTime(luxon) {
|
|
|
758
758
|
value = value.replace(RE_WILDCARDS, `${low}-${high}`);
|
|
759
759
|
|
|
760
760
|
// commas separate information, so split based on those
|
|
761
|
-
|
|
761
|
+
const allRanges = value.split(',');
|
|
762
762
|
|
|
763
|
-
for (
|
|
763
|
+
for (let i = 0; i < allRanges.length; i++) {
|
|
764
764
|
if (allRanges[i].match(RE_RANGE)) {
|
|
765
765
|
allRanges[i].replace(RE_RANGE, ($0, lower, upper, step) => {
|
|
766
766
|
lower = parseInt(lower, 10);
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cron",
|
|
3
3
|
"description": "Cron jobs for your node",
|
|
4
|
-
"version": "2.3.
|
|
4
|
+
"version": "2.3.1",
|
|
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"
|
|
@@ -13,26 +13,25 @@
|
|
|
13
13
|
"main": "lib/cron",
|
|
14
14
|
"scripts": {
|
|
15
15
|
"lint": "eslint {lib,tests}/*.js",
|
|
16
|
-
"test": "jest --coverage"
|
|
16
|
+
"test": "jest --coverage",
|
|
17
|
+
"test:watch": "jest --watch --coverage"
|
|
17
18
|
},
|
|
18
19
|
"dependencies": {
|
|
19
20
|
"luxon": "^3.2.1"
|
|
20
21
|
},
|
|
21
22
|
"devDependencies": {
|
|
22
23
|
"chai": "~4.2.x",
|
|
23
|
-
"eslint": "~
|
|
24
|
-
"eslint-config-prettier": "^
|
|
25
|
-
"eslint-config-standard": "~
|
|
26
|
-
"eslint-
|
|
27
|
-
"eslint-plugin-
|
|
28
|
-
"eslint-plugin-
|
|
29
|
-
"eslint-plugin-
|
|
30
|
-
"eslint-plugin-
|
|
31
|
-
"
|
|
32
|
-
"
|
|
33
|
-
"
|
|
34
|
-
"prettier": "~2.0.x",
|
|
35
|
-
"sinon": "^9.0.x"
|
|
24
|
+
"eslint": "~8.36.x",
|
|
25
|
+
"eslint-config-prettier": "^8.7.x",
|
|
26
|
+
"eslint-config-standard": "~17.0.x",
|
|
27
|
+
"eslint-plugin-import": "~2.27.x",
|
|
28
|
+
"eslint-plugin-jest": "~27.2.x",
|
|
29
|
+
"eslint-plugin-n": "~15.6.x",
|
|
30
|
+
"eslint-plugin-prettier": "~4.2.x",
|
|
31
|
+
"eslint-plugin-promise": "~6.1.x",
|
|
32
|
+
"jest": "~29.5.x",
|
|
33
|
+
"prettier": "~2.8.x",
|
|
34
|
+
"sinon": "^15.0.x"
|
|
36
35
|
},
|
|
37
36
|
"keywords": [
|
|
38
37
|
"cron",
|
|
@@ -45,6 +44,7 @@
|
|
|
45
44
|
],
|
|
46
45
|
"license": "MIT",
|
|
47
46
|
"contributors": [
|
|
47
|
+
"Brandon der Blätter <https://interlucid.com/contact/> (https://github.com/intcreator)",
|
|
48
48
|
"Romain Beauxis <toots@rastageeks.org> (https://github.com/toots)",
|
|
49
49
|
"James Padolsey <> (https://github.com/jamespadolsey)",
|
|
50
50
|
"Finn Herpich <fh@three-heads.de> (https://github.com/ErrorProne)",
|
|
@@ -73,5 +73,11 @@
|
|
|
73
73
|
"lines": 80
|
|
74
74
|
}
|
|
75
75
|
}
|
|
76
|
-
}
|
|
76
|
+
},
|
|
77
|
+
"files": [
|
|
78
|
+
"lib",
|
|
79
|
+
"CHANGELOG.md",
|
|
80
|
+
"LICENSE",
|
|
81
|
+
"README.md"
|
|
82
|
+
]
|
|
77
83
|
}
|
package/.editorconfig
DELETED
package/.eslintrc
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"extends": ["standard", "prettier", "prettier/standard"],
|
|
3
|
-
"parserOptions": {
|
|
4
|
-
"ecmaVersion": 2018
|
|
5
|
-
},
|
|
6
|
-
"globals": {
|
|
7
|
-
"define": "readonly"
|
|
8
|
-
},
|
|
9
|
-
"env": {
|
|
10
|
-
"browser": true,
|
|
11
|
-
"es6": true,
|
|
12
|
-
"node": true,
|
|
13
|
-
"jest/globals": true
|
|
14
|
-
},
|
|
15
|
-
"plugins": ["prettier", "standard", "jest"],
|
|
16
|
-
"rules": {
|
|
17
|
-
"space-before-function-paren": 0,
|
|
18
|
-
"new-cap": 0,
|
|
19
|
-
"prettier/prettier": 2,
|
|
20
|
-
"jest/no-disabled-tests": 1,
|
|
21
|
-
"jest/no-focused-tests": 2,
|
|
22
|
-
"jest/no-identical-title": 2,
|
|
23
|
-
"jest/prefer-to-have-length": 1,
|
|
24
|
-
"jest/valid-expect": 2
|
|
25
|
-
}
|
|
26
|
-
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
name: Bug
|
|
2
|
-
description: Report a bug found in the bot's source code
|
|
3
|
-
labels: ["🛠 goal: fix"]
|
|
4
|
-
body:
|
|
5
|
-
- type: textarea
|
|
6
|
-
id: description
|
|
7
|
-
attributes:
|
|
8
|
-
label: Description
|
|
9
|
-
description: A brief description of the question or issue, also include what you tried and what didn't work
|
|
10
|
-
validations:
|
|
11
|
-
required: true
|
|
12
|
-
- type: textarea
|
|
13
|
-
id: screenshots
|
|
14
|
-
attributes:
|
|
15
|
-
label: Screenshots
|
|
16
|
-
description: Please add screenshots if applicable
|
|
17
|
-
validations:
|
|
18
|
-
required: false
|
|
19
|
-
- type: textarea
|
|
20
|
-
id: extrainfo
|
|
21
|
-
attributes:
|
|
22
|
-
label: Additional information
|
|
23
|
-
description: Is there anything else we should know about this bug?
|
|
24
|
-
validations:
|
|
25
|
-
required: false
|
|
26
|
-
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
name: Feature request
|
|
2
|
-
description: Suggest features, propose improvements, discuss new ideas
|
|
3
|
-
title: "[FEATURE] <description>"
|
|
4
|
-
labels: ["⭐ goal: addition"]
|
|
5
|
-
body:
|
|
6
|
-
- type: textarea
|
|
7
|
-
id: suggestion
|
|
8
|
-
attributes:
|
|
9
|
-
label: ⭐ Suggestion
|
|
10
|
-
description: A summary of what you'd like to see added or changed
|
|
11
|
-
validations:
|
|
12
|
-
required: true
|
|
13
|
-
- type: textarea
|
|
14
|
-
id: usecases
|
|
15
|
-
attributes:
|
|
16
|
-
label: 💻 Use Cases
|
|
17
|
-
description: |
|
|
18
|
-
What are possible test cases for your suggested feature?
|
|
19
|
-
Are you using any workarounds in the meantime?
|
|
20
|
-
validations:
|
|
21
|
-
required: false
|
|
22
|
-
- type: textarea
|
|
23
|
-
id: relatedproblems
|
|
24
|
-
attributes:
|
|
25
|
-
label: ❌ Related Problems
|
|
26
|
-
description: |
|
|
27
|
-
Is your Request related to a problem?
|
|
28
|
-
Think about linking existing Issues here!
|
|
29
|
-
validations:
|
|
30
|
-
required: false
|
|
31
|
-
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node
|
|
2
|
-
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
|
|
3
|
-
|
|
4
|
-
name: CI
|
|
5
|
-
|
|
6
|
-
on:
|
|
7
|
-
push:
|
|
8
|
-
branches:
|
|
9
|
-
- master
|
|
10
|
-
pull_request:
|
|
11
|
-
branches:
|
|
12
|
-
- master
|
|
13
|
-
|
|
14
|
-
jobs:
|
|
15
|
-
build:
|
|
16
|
-
|
|
17
|
-
runs-on: ${{ matrix.os }}
|
|
18
|
-
|
|
19
|
-
strategy:
|
|
20
|
-
matrix:
|
|
21
|
-
node: [14.x, 16.x, 18.x]
|
|
22
|
-
os: [ubuntu-latest, windows-latest, macos-latest]
|
|
23
|
-
|
|
24
|
-
steps:
|
|
25
|
-
- uses: actions/checkout@v2
|
|
26
|
-
- name: Use Node.js ${{ matrix.node }}
|
|
27
|
-
uses: actions/setup-node@v1
|
|
28
|
-
with:
|
|
29
|
-
node-version: ${{ matrix.node }}
|
|
30
|
-
- run: npm ci
|
|
31
|
-
- run: npm run build --if-present
|
|
32
|
-
- run: npm test
|
|
33
|
-
env:
|
|
34
|
-
CI: true
|
|
35
|
-
- run: npm run lint
|
|
36
|
-
|
|
37
|
-
- name: Codecov
|
|
38
|
-
if: ${{ matrix.os == 'ubuntu-latest' && matrix.node == '12.x' }}
|
|
39
|
-
uses: codecov/codecov-action@v1.0.6
|
package/.prettierrc
DELETED
package/bower.json
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "cronjs",
|
|
3
|
-
"homepage": "https://github.com/ncb000gt/node-cron",
|
|
4
|
-
"authors": [
|
|
5
|
-
"Romain Beauxis<toots@rastageeks.org>",
|
|
6
|
-
"James Padoulsey<@padolsey>",
|
|
7
|
-
"Craig Condon<craig@browsertap.com>",
|
|
8
|
-
"Finn Herpich",
|
|
9
|
-
"cliftonc",
|
|
10
|
-
"neyric",
|
|
11
|
-
"humanchimp",
|
|
12
|
-
"danhbear",
|
|
13
|
-
"Jordan Abderrachid<jabderrachid@gmail.com>"
|
|
14
|
-
],
|
|
15
|
-
"description": "js cron handler",
|
|
16
|
-
"main": ["lib/cron.js"],
|
|
17
|
-
"keywords": [
|
|
18
|
-
"cron",
|
|
19
|
-
"js"
|
|
20
|
-
],
|
|
21
|
-
"license": "MIT",
|
|
22
|
-
"ignore": [
|
|
23
|
-
"**/.*",
|
|
24
|
-
"node_modules",
|
|
25
|
-
"bower_components",
|
|
26
|
-
"test",
|
|
27
|
-
"tests"
|
|
28
|
-
]
|
|
29
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
const CronJob = require('../lib/cron.js').CronJob;
|
|
2
|
-
|
|
3
|
-
console.log('Before job instantiation');
|
|
4
|
-
const job = new CronJob('* 10 * * * *', function() {
|
|
5
|
-
const d = new Date();
|
|
6
|
-
console.log('At Ten Minutes:', d);
|
|
7
|
-
});
|
|
8
|
-
console.log('After job instantiation');
|
|
9
|
-
job.start();
|
package/examples/at_midnight.js
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
const CronJob = require('../lib/cron.js').CronJob;
|
|
2
|
-
|
|
3
|
-
console.log('Before job instantiation');
|
|
4
|
-
const job = new CronJob('00 00 00 * * *', function() {
|
|
5
|
-
const d = new Date();
|
|
6
|
-
console.log('Midnight:', d);
|
|
7
|
-
});
|
|
8
|
-
console.log('After job instantiation');
|
|
9
|
-
job.start();
|
package/examples/basic.js
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
const CronJob = require('../lib/cron.js').CronJob;
|
|
2
|
-
|
|
3
|
-
console.log('Before job instantiation');
|
|
4
|
-
const job = new CronJob('* * * * * *', function() {
|
|
5
|
-
const d = new Date();
|
|
6
|
-
console.log('Every second:', d);
|
|
7
|
-
});
|
|
8
|
-
console.log('After job instantiation');
|
|
9
|
-
job.start();
|