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