(job, prefix, config)
| 67 | }; |
| 68 | |
| 69 | const 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 | |
| 113 | const cronValidateWithSeconds = (job, config) => { |
| 114 | const preset = |
no test coverage detected
searching dependent graphs…