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

Function writeLockFile

src/utils/nativeInstaller/pidLock.ts:210–232  ·  view source on GitHub ↗

* Write lock content to a file atomically

(
  lockFilePath: string,
  content: VersionLockContent,
)

Source from the content-addressed store, hash-verified

208 * Write lock content to a file atomically
209 */
210function writeLockFile(
211 lockFilePath: string,
212 content: VersionLockContent,
213): void {
214 const fs = getFsImplementation()
215 const tempPath = `${lockFilePath}.tmp.${process.pid}.${Date.now()}`
216
217 try {
218 writeFileSync_DEPRECATED(tempPath, jsonStringify(content, null, 2), {
219 encoding: 'utf8',
220 flush: true,
221 })
222 fs.renameSync(tempPath, lockFilePath)
223 } catch (error) {
224 // Clean up temp file on failure (best-effort)
225 try {
226 fs.unlinkSync(tempPath)
227 } catch {
228 // Ignore cleanup errors (ENOENT expected if write failed before file creation)
229 }
230 throw error
231 }
232}
233
234/**
235 * Try to acquire a lock on a version file

Callers 1

tryAcquireLockFunction · 0.85

Calls 3

getFsImplementationFunction · 0.85
writeFileSync_DEPRECATEDFunction · 0.85
jsonStringifyFunction · 0.85

Tested by

no test coverage detected