( taskListId: string, taskId: string, updates: Partial<Omit<Task, 'id'>>, )
| 368 | } |
| 369 | |
| 370 | export async function updateTask( |
| 371 | taskListId: string, |
| 372 | taskId: string, |
| 373 | updates: Partial<Omit<Task, 'id'>>, |
| 374 | ): Promise<Task | null> { |
| 375 | const path = getTaskPath(taskListId, taskId) |
| 376 | |
| 377 | // Check existence before locking — proper-lockfile throws if the |
| 378 | // target file doesn't exist, and we want a clean null result. |
| 379 | const taskBeforeLock = await getTask(taskListId, taskId) |
| 380 | if (!taskBeforeLock) { |
| 381 | return null |
| 382 | } |
| 383 | |
| 384 | let release: (() => Promise<void>) | undefined |
| 385 | try { |
| 386 | release = await lockfile.lock(path, LOCK_OPTIONS) |
| 387 | return await updateTaskUnsafe(taskListId, taskId, updates) |
| 388 | } finally { |
| 389 | await release?.() |
| 390 | } |
| 391 | } |
| 392 | |
| 393 | export async function deleteTask( |
| 394 | taskListId: string, |
no test coverage detected