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