mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-30 21:40:39 +03:00
35 lines
806 B
JavaScript
35 lines
806 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,
|
|
// NOTE: avoids executing job immidiately after initialization
|
|
// can remove it when https://github.com/breejs/bree/issues/50 is fixed
|
|
timeout: false
|
|
};
|
|
|
|
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;
|