( versionPath: string, lockFilePath: string, callback: () => void | Promise<void>, )
| 328 | * Returns true if the callback executed, false if lock couldn't be acquired |
| 329 | */ |
| 330 | export async function withLock( |
| 331 | versionPath: string, |
| 332 | lockFilePath: string, |
| 333 | callback: () => void | Promise<void>, |
| 334 | ): Promise<boolean> { |
| 335 | const release = await tryAcquireLock(versionPath, lockFilePath) |
| 336 | |
| 337 | if (!release) { |
| 338 | return false |
| 339 | } |
| 340 | |
| 341 | try { |
| 342 | await callback() |
| 343 | return true |
| 344 | } finally { |
| 345 | release() |
| 346 | } |
| 347 | } |
| 348 | |
| 349 | /** |
| 350 | * Get information about all version locks for diagnostics |
no test coverage detected