mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-28 05:37:34 +03:00
a7b523e0f3
refs https://github.com/breejs/bree/issues/50
refs f1ab159
- This bree version allows to avoid additional flag setting when initializing scheduled job
32 lines
631 B
JavaScript
32 lines
631 B
JavaScript
const isCronExpression = require('./is-cron-expression');
|
|
|
|
const assemble = (when, job, data, name) => {
|
|
const breeJob = {
|
|
name: name,
|
|
// NOTE: both function and path syntaxes work with 'path' parameter
|
|
path: job
|
|
};
|
|
|
|
if (data) {
|
|
Object.assign(breeJob, {
|
|
worker: {
|
|
workerData: data
|
|
}
|
|
});
|
|
}
|
|
|
|
if (isCronExpression(when)) {
|
|
Object.assign(breeJob, {
|
|
cron: when
|
|
});
|
|
} else {
|
|
Object.assign(breeJob, {
|
|
interval: when
|
|
});
|
|
}
|
|
|
|
return breeJob;
|
|
};
|
|
|
|
module.exports = assemble;
|