MCPcopy Create free account
hub / github.com/Noumena-Network/code / writeCronTasks

Function writeCronTasks

src/utils/cronTasks.ts:183–200  ·  view source on GitHub ↗
(
  tasks: CronTask[],
  dir?: string,
)

Source from the content-addressed store, hash-verified

181 * deleting) so the file watcher sees a change event on last-task-removed.
182 */
183export async function writeCronTasks(
184 tasks: CronTask[],
185 dir?: string,
186): Promise<void> {
187 const root = dir ?? getProjectRoot()
188 await mkdir(join(root, '.ncode'), { recursive: true })
189 // Strip the runtime-only `durable` flag — everything on disk is durable
190 // by definition, and keeping the flag out means readCronTasks() naturally
191 // yields durable: undefined without having to set it explicitly.
192 const body: CronFile = {
193 tasks: tasks.map(({ durable: _durable, ...rest }) => rest),
194 }
195 await writeFile(
196 getCronFilePath(root),
197 jsonStringify(body, null, 2) + '\n',
198 'utf-8',
199 )
200}
201
202/**
203 * Append a task. Returns the generated id. Caller is responsible for having

Callers 4

addCronTaskFunction · 0.85
removeCronTasksFunction · 0.85
markCronTasksFiredFunction · 0.85

Calls 4

getProjectRootFunction · 0.85
mkdirFunction · 0.85
getCronFilePathFunction · 0.85
jsonStringifyFunction · 0.85

Tested by

no test coverage detected