sails-hook-quest 0.0.1 → 0.0.2
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/lib/core/loader.js +2 -1
- package/lib/core/scheduler.js +11 -4
- package/package.json +1 -1
package/lib/core/loader.js
CHANGED
|
@@ -135,8 +135,9 @@ function addJobDefinition(jobDef, jobs = new Map(), config = {}) {
|
|
|
135
135
|
interval: jobDef.interval,
|
|
136
136
|
timeout: jobDef.timeout,
|
|
137
137
|
cron: jobDef.cron,
|
|
138
|
-
|
|
138
|
+
cronOptions: jobDef.cronOptions,
|
|
139
139
|
date: jobDef.date,
|
|
140
|
+
timezone: jobDef.timezone,
|
|
140
141
|
|
|
141
142
|
// Input data to pass to the script
|
|
142
143
|
inputs: jobDef.inputs || {},
|
package/lib/core/scheduler.js
CHANGED
|
@@ -16,15 +16,22 @@ const { CronExpressionParser } = require('cron-parser')
|
|
|
16
16
|
*/
|
|
17
17
|
function getNextRunTime(job, config = {}) {
|
|
18
18
|
const now = new Date()
|
|
19
|
-
const timezone = config.timezone
|
|
19
|
+
const timezone = job.timezone || config.timezone
|
|
20
|
+
|
|
21
|
+
// Validate: cannot combine date and timeout
|
|
22
|
+
if (job.date && job.timeout !== undefined && job.timeout !== false) {
|
|
23
|
+
throw new Error(
|
|
24
|
+
`Job "${job.name}": Cannot combine 'date' and 'timeout'. Use one or the other.`
|
|
25
|
+
)
|
|
26
|
+
}
|
|
20
27
|
|
|
21
28
|
// Handle cron expressions
|
|
22
29
|
if (job.cron) {
|
|
23
30
|
try {
|
|
24
31
|
const options = { tz: timezone }
|
|
25
|
-
// Merge any
|
|
26
|
-
if (job.
|
|
27
|
-
Object.assign(options, job.
|
|
32
|
+
// Merge any cron-parser options (currentDate, startDate, endDate, etc.)
|
|
33
|
+
if (job.cronOptions) {
|
|
34
|
+
Object.assign(options, job.cronOptions)
|
|
28
35
|
}
|
|
29
36
|
const interval = CronExpressionParser.parse(job.cron, options)
|
|
30
37
|
return interval.next().toDate()
|
package/package.json
CHANGED