MCPcopy Index your code
hub / github.com/codeaashu/claude-code / withLock

Function withLock

src/utils/nativeInstaller/pidLock.ts:330–347  ·  view source on GitHub ↗
(
  versionPath: string,
  lockFilePath: string,
  callback: () => void | Promise<void>,
)

Source from the content-addressed store, hash-verified

328 * Returns true if the callback executed, false if lock couldn't be acquired
329 */
330export 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

Callers 1

tryWithVersionLockFunction · 0.85

Calls 2

tryAcquireLockFunction · 0.85
releaseFunction · 0.50

Tested by

no test coverage detected