(dir?: string)
| 162 | * cronScheduler.start() to decide whether to auto-enable. One file read. |
| 163 | */ |
| 164 | export function hasCronTasksSync(dir?: string): boolean { |
| 165 | let raw: string |
| 166 | try { |
| 167 | // eslint-disable-next-line custom-rules/no-sync-fs -- called once from cronScheduler.start() |
| 168 | raw = readFileSync(getReadableCronFilePath(dir), 'utf-8') |
| 169 | } catch { |
| 170 | return false |
| 171 | } |
| 172 | const parsed = safeParseJSON(raw, false) |
| 173 | if (!parsed || typeof parsed !== 'object') return false |
| 174 | const tasks = (parsed as Partial<CronFile>).tasks |
| 175 | return Array.isArray(tasks) && tasks.length > 0 |
| 176 | } |
| 177 | |
| 178 | /** |
| 179 | * Overwrite the canonical .ncode/scheduled_tasks.json with the given tasks. |
no test coverage detected