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

Function validateJobPath

src/job-validator.js:69–111  ·  view source on GitHub ↗
(job, prefix, config)

Source from the content-addressed store, hash-verified

67};
68
69const validateJobPath = async (job, prefix, config) => {
70 const errors = [];
71
72 if (typeof job.path === 'function') {
73 const path = `(${job.path.toString()})()`;
74
75 // Can't be a built-in or bound function
76 if (path.includes('[native code]')) {
77 errors.push(new Error(`${prefix} can't be a bound or built-in function`));
78 }
79 } else if (!isSANB(job.path) && !config.root) {
80 errors.push(
81 new Error(
82 `${prefix} requires root directory option to auto-populate path`
83 )
84 );
85 } else {
86 // Validate path
87 const path = isSANB(job.path)
88 ? job.path
89 : join(
90 config.root,
91 getJobPath(
92 job.name,
93 config.acceptedExtensions,
94 config.defaultExtension
95 )
96 );
97 if (!isInvalidPath(path)) {
98 try {
99 const stats = await fs.promises.stat(path);
100 if (!stats.isFile()) {
101 throw new Error(`${prefix} path missing: ${path}`);
102 }
103 } catch (err) {
104 /* istanbul ignore next */
105 errors.push(err);
106 }
107 }
108 }
109
110 return errors;
111};
112
113const cronValidateWithSeconds = (job, config) => {
114 const preset =

Callers 1

validateFunction · 0.85

Calls 2

isSANBFunction · 0.85
getJobPathFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…