cron 4.2.1-beta.1 → 5.0.0-beta.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/CHANGELOG.md +28 -0
- package/README.md +1 -2
- package/dist/job.d.ts +1 -1
- package/dist/job.js +5 -18
- package/dist/types/cron.types.d.ts +2 -8
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,31 @@
|
|
|
1
|
+
## [5.0.0-beta.1](https://github.com/kelektiv/node-cron/compare/v4.3.0...v5.0.0-beta.1) (2025-04-19)
|
|
2
|
+
|
|
3
|
+
### ⚠ Breaking changes
|
|
4
|
+
|
|
5
|
+
* Removed the ability to execute system commands using
|
|
6
|
+
string-based inputs. This eliminates the dependency on `child_process`,
|
|
7
|
+
improving browser compatibility. Users relying on this functionality
|
|
8
|
+
should migrate to executing commands manually within their own
|
|
9
|
+
implementations.
|
|
10
|
+
## Related Issue
|
|
11
|
+
|
|
12
|
+
<!--- This project only accepts pull requests related to open issues -->
|
|
13
|
+
<!--- If suggesting a new feature or change, please discuss it in an
|
|
14
|
+
issue first -->
|
|
15
|
+
<!--- If fixing a bug, there should be an issue describing it with steps
|
|
16
|
+
to reproduce -->
|
|
17
|
+
<!--- Please link to the issue here: -->
|
|
18
|
+
|
|
19
|
+
### ✨ Features
|
|
20
|
+
|
|
21
|
+
* remove `child_process` dependency for browser compatibility (#… ([#982](https://github.com/kelektiv/node-cron/issues/982)) ([69cb9e6](https://github.com/kelektiv/node-cron/commit/69cb9e6fec5b1f901084e44c6068c4e5ae4ba980)), closes [#967](https://github.com/kelektiv/node-cron/issues/967)
|
|
22
|
+
|
|
23
|
+
## [4.3.0](https://github.com/kelektiv/node-cron/compare/v4.2.0...v4.3.0) (2025-04-15)
|
|
24
|
+
|
|
25
|
+
### ✨ Features
|
|
26
|
+
|
|
27
|
+
* add options to handle cases where jobs could stop unexpectedly ([#980](https://github.com/kelektiv/node-cron/issues/980)) ([994b93a](https://github.com/kelektiv/node-cron/commit/994b93ab2f41af729c4928f5999e2487a67f611d)), closes [#963](https://github.com/kelektiv/node-cron/issues/963) [#962](https://github.com/kelektiv/node-cron/issues/962) [#962](https://github.com/kelektiv/node-cron/issues/962) [#963](https://github.com/kelektiv/node-cron/issues/963)
|
|
28
|
+
|
|
1
29
|
## [4.2.1-beta.1](https://github.com/kelektiv/node-cron/compare/v4.2.0...v4.2.1-beta.1) (2025-04-15)
|
|
2
30
|
|
|
3
31
|
### 🐛 Bug Fixes
|
package/README.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<p align="center">
|
|
2
2
|
<img src="logo.svg" alt="cron for Node.js logo" height="150">
|
|
3
3
|
<br />
|
|
4
|
-
<b>cron</b> is a robust tool for running jobs (functions
|
|
4
|
+
<b>cron</b> is a robust tool for running jobs (functions) on schedules defined using the cron syntax.
|
|
5
5
|
<br />
|
|
6
6
|
Perfect for tasks like data backups, notifications, and many more!
|
|
7
7
|
</p>
|
|
@@ -20,7 +20,6 @@
|
|
|
20
20
|
## 🌟 Features
|
|
21
21
|
|
|
22
22
|
- execute a function whenever your scheduled job triggers
|
|
23
|
-
- execute a job external to the javascript process (like a system command) using `child_process`
|
|
24
23
|
- use a Date or Luxon DateTime object instead of cron syntax as the trigger for your callback
|
|
25
24
|
- use an additional slot for seconds (leaving it off will default to 0 and match the Unix behavior)
|
|
26
25
|
|
package/dist/job.d.ts
CHANGED
|
@@ -20,7 +20,7 @@ export declare class CronJob<OC extends CronOnCompleteCommand | null = null, C =
|
|
|
20
20
|
constructor(cronTime: CronJobParams<OC, C>['cronTime'], onTick: CronJobParams<OC, C>['onTick'], onComplete?: CronJobParams<OC, C>['onComplete'], start?: CronJobParams<OC, C>['start'], timeZone?: CronJobParams<OC, C>['timeZone'], context?: CronJobParams<OC, C>['context'], runOnInit?: CronJobParams<OC, C>['runOnInit'], utcOffset?: null, unrefTimeout?: CronJobParams<OC, C>['unrefTimeout'], waitForCompletion?: CronJobParams<OC, C>['waitForCompletion'], errorHandler?: CronJobParams<OC, C>['errorHandler'], name?: CronJobParams<OC, C>['name'], threshold?: CronJobParams<OC, C>['threshold']);
|
|
21
21
|
constructor(cronTime: CronJobParams<OC, C>['cronTime'], onTick: CronJobParams<OC, C>['onTick'], onComplete?: CronJobParams<OC, C>['onComplete'], start?: CronJobParams<OC, C>['start'], timeZone?: null, context?: CronJobParams<OC, C>['context'], runOnInit?: CronJobParams<OC, C>['runOnInit'], utcOffset?: CronJobParams<OC, C>['utcOffset'], unrefTimeout?: CronJobParams<OC, C>['unrefTimeout'], waitForCompletion?: CronJobParams<OC, C>['waitForCompletion'], errorHandler?: CronJobParams<OC, C>['errorHandler'], name?: CronJobParams<OC, C>['name'], threshold?: CronJobParams<OC, C>['threshold']);
|
|
22
22
|
static from<OC extends CronOnCompleteCommand | null = null, C = null>(params: CronJobParams<OC, C>): CronJob<OC, C>;
|
|
23
|
-
private
|
|
23
|
+
private isCronOnCompleteCallback;
|
|
24
24
|
addCallback(callback: CronCallback<C, WithOnComplete<OC>>): void;
|
|
25
25
|
setTime(time: CronTime): void;
|
|
26
26
|
nextDate(): import("luxon").DateTime<boolean>;
|
package/dist/job.js
CHANGED
|
@@ -10,7 +10,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.CronJob = void 0;
|
|
13
|
-
const child_process_1 = require("child_process");
|
|
14
13
|
const errors_1 = require("./errors");
|
|
15
14
|
const time_1 = require("./time");
|
|
16
15
|
class CronJob {
|
|
@@ -47,8 +46,8 @@ class CronJob {
|
|
|
47
46
|
if (unrefTimeout != null) {
|
|
48
47
|
this.unrefTimeout = unrefTimeout;
|
|
49
48
|
}
|
|
50
|
-
if (onComplete
|
|
51
|
-
this.onComplete =
|
|
49
|
+
if (this.isCronOnCompleteCallback(onComplete)) {
|
|
50
|
+
this.onComplete = onComplete;
|
|
52
51
|
}
|
|
53
52
|
if (threshold != null) {
|
|
54
53
|
this.threshold = Math.abs(threshold);
|
|
@@ -59,7 +58,7 @@ class CronJob {
|
|
|
59
58
|
if (this.cronTime.realDate) {
|
|
60
59
|
this.runOnce = true;
|
|
61
60
|
}
|
|
62
|
-
this.addCallback(
|
|
61
|
+
this.addCallback(onTick);
|
|
63
62
|
if (runOnInit) {
|
|
64
63
|
this.lastExecution = new Date();
|
|
65
64
|
void this.fireOnTick();
|
|
@@ -81,20 +80,8 @@ class CronJob {
|
|
|
81
80
|
return new CronJob(params.cronTime, params.onTick, params.onComplete, params.start, params.timeZone, params.context, params.runOnInit, params.utcOffset, params.unrefTimeout, params.waitForCompletion, params.errorHandler, params.name, params.threshold);
|
|
82
81
|
}
|
|
83
82
|
}
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
switch (typeof cmd) {
|
|
87
|
-
case 'function': {
|
|
88
|
-
return cmd;
|
|
89
|
-
}
|
|
90
|
-
case 'string': {
|
|
91
|
-
const [command, ...args] = cmd.split(' ');
|
|
92
|
-
return child_process_1.spawn.bind(undefined, command !== null && command !== void 0 ? command : cmd, args, {});
|
|
93
|
-
}
|
|
94
|
-
case 'object': {
|
|
95
|
-
return child_process_1.spawn.bind(undefined, cmd.command, (_a = cmd.args) !== null && _a !== void 0 ? _a : [], (_b = cmd.options) !== null && _b !== void 0 ? _b : {});
|
|
96
|
-
}
|
|
97
|
-
}
|
|
83
|
+
isCronOnCompleteCallback(fn) {
|
|
84
|
+
return typeof fn === 'function';
|
|
98
85
|
}
|
|
99
86
|
addCallback(callback) {
|
|
100
87
|
if (typeof callback === 'function') {
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { SpawnOptions } from 'child_process';
|
|
2
1
|
import { DateTime } from 'luxon';
|
|
3
2
|
import { CONSTRAINTS, TIME_UNITS_MAP } from '../constants';
|
|
4
3
|
import { CronJob } from '../job';
|
|
@@ -26,13 +25,8 @@ export type CronJobParams<OC extends CronOnCompleteCommand | null = null, C = nu
|
|
|
26
25
|
export type CronContext<C> = C extends null ? CronJob : NonNullable<C>;
|
|
27
26
|
export type CronCallback<C, WithOnCompleteBool extends boolean = false> = (this: CronContext<C>, onComplete: WithOnCompleteBool extends true ? CronOnCompleteCallback : never) => void | Promise<void>;
|
|
28
27
|
export type CronOnCompleteCallback = () => void | Promise<void>;
|
|
29
|
-
export type
|
|
30
|
-
|
|
31
|
-
args?: readonly string[] | null;
|
|
32
|
-
options?: SpawnOptions | null;
|
|
33
|
-
};
|
|
34
|
-
export type CronCommand<C, WithOnCompleteBool extends boolean = false> = CronCallback<C, WithOnCompleteBool> | CronSystemCommand;
|
|
35
|
-
export type CronOnCompleteCommand = CronOnCompleteCallback | CronSystemCommand;
|
|
28
|
+
export type CronCommand<C, WithOnCompleteBool extends boolean = false> = CronCallback<C, WithOnCompleteBool>;
|
|
29
|
+
export type CronOnCompleteCommand = CronOnCompleteCallback;
|
|
36
30
|
export type WithOnComplete<OC> = OC extends null ? false : true;
|
|
37
31
|
export type TimeUnit = (typeof TIME_UNITS_MAP)[keyof typeof TIME_UNITS_MAP];
|
|
38
32
|
export type TimeUnitField<T extends TimeUnit> = Partial<Record<Ranges[T], boolean>>;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cron",
|
|
3
3
|
"description": "Cron jobs for your node",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "5.0.0-beta.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"
|