Comparing version 1.1.25 to 1.1.26
47
index.js
@@ -500,6 +500,9 @@ const EventEmitter = require('events'); | ||
// and date was undefined then set the default | ||
// (as long as the default interval is > 0) | ||
// (as long as the default interval is > 0, or it was a schedule, or it was valid) | ||
if ( | ||
Number.isFinite(this.config.interval) && | ||
this.config.interval > 0 && | ||
((Number.isFinite(this.config.interval) && this.config.interval > 0) || | ||
(typeof this.config.interval === 'object' && | ||
this.isSchedule(this.config.interval)) || | ||
(typeof this.config.interval === 'object' && | ||
typeof this.config.interval.isValid === 'function')) && | ||
typeof this.config.jobs[i].interval === 'undefined' && | ||
@@ -563,2 +566,3 @@ typeof job.cron === 'undefined' && | ||
// eslint-disable-next-line complexity | ||
run(name) { | ||
@@ -575,7 +579,37 @@ debug('run', name); | ||
debug('starting worker', name); | ||
this.workers[name] = new Worker(job.path, { | ||
const object = { | ||
...(this.config.worker ? this.config.worker : {}), | ||
...(job.worker ? job.worker : {}), | ||
workerData: { | ||
job, | ||
job: { | ||
...job, | ||
// <https://github.com/breejs/bree/issues/23> | ||
...(typeof job.cron === 'undefined' | ||
? {} | ||
: { | ||
cron: this.isSchedule(job.cron) | ||
? '[schedule]' | ||
: typeof job.cron.isValid === 'function' | ||
? '[later]' | ||
: job.cron | ||
}), | ||
...(typeof job.timeout === 'undefined' | ||
? {} | ||
: { | ||
timeout: this.isSchedule(job.timeout) | ||
? '[schedule]' | ||
: typeof job.timeout.isValid === 'function' | ||
? '[later]' | ||
: job.timeout | ||
}), | ||
...(typeof job.interval === 'undefined' | ||
? {} | ||
: { | ||
interval: this.isSchedule(job.interval) | ||
? '[schedule]' | ||
: typeof job.interval.isValid === 'function' | ||
? '[later]' | ||
: job.interval | ||
}) | ||
}, | ||
...(this.config.worker && this.config.worker.workerData | ||
@@ -586,3 +620,4 @@ ? this.config.worker.workerData | ||
} | ||
}); | ||
}; | ||
this.workers[name] = new Worker(job.path, object); | ||
this.emit('worker created', name); | ||
@@ -589,0 +624,0 @@ debug('worker started', name); |
{ | ||
"name": "bree", | ||
"description": "The best job scheduler for Node.js with support for cron, dates, ms, later, and human-friendly strings. Uses workers to spawn sandboxed processes, and supports async/await, retries, throttling, concurrency, and cancelable promises (graceful shutdown). Simple, fast, and the most lightweight tool for the job. Made for Forward Email and Lad.", | ||
"version": "1.1.25", | ||
"version": "1.1.26", | ||
"author": "Nick Baugh <niftylettuce@gmail.com> (http://niftylettuce.com/)", | ||
@@ -6,0 +6,0 @@ "ava": { |
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
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
74464
786