Comparing version 3.3.2 to 3.4.0
@@ -12,2 +12,3 @@ import { CronTime } from './time'; | ||
waitForCompletion: boolean; | ||
errorHandler?: CronJobParams<OC, C>['errorHandler']; | ||
private _isCallbackRunning; | ||
@@ -17,4 +18,4 @@ private _timeout?; | ||
get isCallbackRunning(): boolean; | ||
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']); | ||
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']); | ||
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']); | ||
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']); | ||
static from<OC extends CronOnCompleteCommand | null = null, C = null>(params: CronJobParams<OC, C>): CronJob<OC, C>; | ||
@@ -21,0 +22,0 @@ private _fnWrap; |
@@ -20,3 +20,3 @@ "use strict"; | ||
} | ||
constructor(cronTime, onTick, onComplete, start, timeZone, context, runOnInit, utcOffset, unrefTimeout, waitForCompletion) { | ||
constructor(cronTime, onTick, onComplete, start, timeZone, context, runOnInit, utcOffset, unrefTimeout, waitForCompletion, errorHandler) { | ||
this.running = false; | ||
@@ -31,2 +31,3 @@ this.unrefTimeout = false; | ||
this.waitForCompletion = Boolean(waitForCompletion); | ||
this.errorHandler = errorHandler; | ||
if (timeZone != null && utcOffset != null) { | ||
@@ -66,9 +67,9 @@ throw new errors_1.ExclusiveParametersError('timeZone', 'utcOffset'); | ||
if (params.timeZone != null) { | ||
return new CronJob(params.cronTime, params.onTick, params.onComplete, params.start, params.timeZone, params.context, params.runOnInit, params.utcOffset, params.unrefTimeout, params.waitForCompletion); | ||
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); | ||
} | ||
else if (params.utcOffset != null) { | ||
return new CronJob(params.cronTime, params.onTick, params.onComplete, params.start, null, params.context, params.runOnInit, params.utcOffset, params.unrefTimeout, params.waitForCompletion); | ||
return new CronJob(params.cronTime, params.onTick, params.onComplete, params.start, null, params.context, params.runOnInit, params.utcOffset, params.unrefTimeout, params.waitForCompletion, params.errorHandler); | ||
} | ||
else { | ||
return new CronJob(params.cronTime, params.onTick, params.onComplete, params.start, params.timeZone, params.context, params.runOnInit, params.utcOffset, params.unrefTimeout, params.waitForCompletion); | ||
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); | ||
} | ||
@@ -124,3 +125,6 @@ } | ||
catch (error) { | ||
console.error('[Cron] error in callback', error); | ||
if (this.errorHandler != null) | ||
this.errorHandler(error); | ||
else | ||
console.error('[Cron] error in callback', error); | ||
} | ||
@@ -127,0 +131,0 @@ finally { |
@@ -15,2 +15,3 @@ import { SpawnOptions } from 'child_process'; | ||
waitForCompletion?: boolean | null; | ||
errorHandler?: ((error: unknown) => void) | null; | ||
} | ||
@@ -17,0 +18,0 @@ export type CronJobParams<OC extends CronOnCompleteCommand | null = null, C = null> = BaseCronJobParams<OC, C> & ({ |
{ | ||
"name": "cron", | ||
"description": "Cron jobs for your node", | ||
"version": "3.3.2", | ||
"version": "3.4.0", | ||
"author": "Nick Campbell <nicholas.j.campbell@gmail.com> (https://github.com/ncb000gt)", | ||
@@ -37,11 +37,11 @@ "bugs": { | ||
"@semantic-release/changelog": "6.0.3", | ||
"@semantic-release/commit-analyzer": "13.0.0", | ||
"@semantic-release/commit-analyzer": "13.0.1", | ||
"@semantic-release/git": "10.0.1", | ||
"@semantic-release/github": "11.0.1", | ||
"@semantic-release/npm": "12.0.1", | ||
"@semantic-release/release-notes-generator": "14.0.2", | ||
"@semantic-release/release-notes-generator": "14.0.3", | ||
"@types/jest": "29.5.14", | ||
"@types/node": "20.17.10", | ||
"@types/node": "20.17.11", | ||
"@types/sinon": "17.0.3", | ||
"chai": "4.5.0", | ||
"chai": "5.1.2", | ||
"eslint": "8.57.1", | ||
@@ -53,6 +53,6 @@ "eslint-config-prettier": "9.1.0", | ||
"jest": "29.7.0", | ||
"lint-staged": "15.2.11", | ||
"lint-staged": "15.3.0", | ||
"prettier": "3.4.2", | ||
"semantic-release": "24.2.0", | ||
"sinon": "17.0.2", | ||
"semantic-release": "24.2.1", | ||
"sinon": "19.0.2", | ||
"ts-jest": "29.2.5", | ||
@@ -59,0 +59,0 @@ "typescript": "5.7.2", |
@@ -199,2 +199,4 @@ <p align="center"> | ||
- `errorHandler`: [OPTIONAL] - Function to handle any exceptions that occur in the `onTick` method. | ||
#### Methods | ||
@@ -201,0 +203,0 @@ |
Sorry, the diff of this file is too big to display
125155
987
271