MCPcopy
hub / github.com/breejs/bree / buildJob

Function buildJob

src/job-builder.js:9–131  ·  view source on GitHub ↗
(job, config)

Source from the content-addressed store, hash-verified

7
8// eslint-disable-next-line complexity
9const buildJob = (job, config) => {
10 if (isSANB(job)) {
11 const path = join(
12 config.root,
13 getJobPath(job, config.acceptedExtensions, config.defaultExtension)
14 );
15
16 const jobObject = {
17 name: job,
18 path,
19 timeout: config.timeout,
20 interval: config.interval
21 };
22 if (isSANB(config.timezone)) {
23 jobObject.timezone = config.timezone;
24 }
25
26 return jobObject;
27 }
28
29 if (typeof job === 'function') {
30 const path = `(${job.toString()})()`;
31
32 const jobObject = {
33 name: job.name,
34 path,
35 worker: { eval: true },
36 timeout: config.timeout,
37 interval: config.interval
38 };
39 if (isSANB(config.timezone)) {
40 jobObject.timezone = config.timezone;
41 }
42
43 return jobObject;
44 }
45
46 // Process job.path
47 if (typeof job.path === 'function') {
48 const path = `(${job.path.toString()})()`;
49
50 job.path = path;
51 job.worker = {
52 eval: true,
53 ...job.worker
54 };
55 } else {
56 const path = isSANB(job.path)
57 ? job.path
58 : join(
59 config.root,
60 getJobPath(
61 job.name,
62 config.acceptedExtensions,
63 config.defaultExtension
64 )
65 );
66

Callers 2

initMethod · 0.85
addMethod · 0.85

Calls 4

isSANBFunction · 0.85
getJobPathFunction · 0.85
parseValueFunction · 0.85
isScheduleFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…