mirror of
https://github.com/Mintplex-Labs/bree.git
synced 2026-07-21 00:45:22 -04:00
refactor: removed cronValidate property from job object
This commit is contained in:
+6
-12
@@ -133,18 +133,18 @@ const validateCron = (job, prefix, config) => {
|
||||
const errors = [];
|
||||
|
||||
if (!isSchedule(job.cron)) {
|
||||
// if `hasSeconds` was `true` then set `cronValidate` and inherit any existing options
|
||||
const cronValidate = job.hasSeconds
|
||||
? cronValidateWithSeconds(job, config)
|
||||
: config.cronValidate;
|
||||
|
||||
//
|
||||
// validate cron pattern
|
||||
// (must support patterns such as `* * L * *` and `0 0/5 14 * * ?` (and aliases too)
|
||||
//
|
||||
// <https://github.com/Airfooox/cron-validate/issues/67>
|
||||
//
|
||||
const result = cron(
|
||||
job.cron,
|
||||
typeof job.cronValidate === 'undefined'
|
||||
? config.cronValidate
|
||||
: job.cronValidate
|
||||
);
|
||||
const result = cron(job.cron, cronValidate);
|
||||
|
||||
if (!result.isValid()) {
|
||||
// NOTE: it is always valid
|
||||
@@ -284,12 +284,6 @@ const validate = (job, i, names = [], config = {}) => {
|
||||
)
|
||||
);
|
||||
|
||||
// if `hasSeconds` was `true` then set `cronValidate` and inherit any existing options
|
||||
if (job.hasSeconds) {
|
||||
job.cronValidate = cronValidateWithSeconds(job, config);
|
||||
}
|
||||
|
||||
// validate cron
|
||||
if (typeof job.cron !== 'undefined') {
|
||||
errors.push(...validateCron(job, prefix, config));
|
||||
}
|
||||
|
||||
@@ -1437,12 +1437,6 @@ test('hasSeconds and job.hasSeconds', (t) => {
|
||||
useSeconds: true
|
||||
}
|
||||
});
|
||||
t.deepEqual(bree.config.jobs[0].cronValidate, {
|
||||
preset: 'default',
|
||||
override: {
|
||||
useSeconds: true
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
test('cronValidate and job.cronValidate', (t) => {
|
||||
|
||||
Reference in New Issue
Block a user