(
fn: (state: WorksetsState) => T | Promise<T>,
options: WorksetPathOptions = {}
)
| 260 | * .code-workspace coherently; the lock is released before any spawn. |
| 261 | */ |
| 262 | export async function withWorksetsLock<T>( |
| 263 | fn: (state: WorksetsState) => T | Promise<T>, |
| 264 | options: WorksetPathOptions = {} |
| 265 | ): Promise<T> { |
| 266 | const lockPath = `${getWorksetsFilePath(options)}.lock`; |
| 267 | const lock = await acquireFileLock({ |
| 268 | lockPath, |
| 269 | errorFor: worksetsLockError, |
| 270 | }); |
| 271 | |
| 272 | try { |
| 273 | return await fn(await readWorksetsState(options)); |
| 274 | } finally { |
| 275 | await releaseFileLock(lock, lockPath); |
| 276 | } |
| 277 | } |
| 278 | |
| 279 | export function worksetNotFoundError( |
| 280 | name: string, |
no test coverage detected