MCPcopy Create free account
hub / github.com/AnukarOP/claude-code-leaked / writeIfMissing

Function writeIfMissing

source code/utils/localInstaller.ts:40–52  ·  view source on GitHub ↗

* Write `content` to `path` only if the file does not already exist. * Uses O_EXCL ('wx') for atomic create-if-missing.

(
  path: string,
  content: string,
  mode?: number,
)

Source from the content-addressed store, hash-verified

38 * Uses O_EXCL ('wx') for atomic create-if-missing.
39 */
40async function writeIfMissing(
41 path: string,
42 content: string,
43 mode?: number,
44): Promise<boolean> {
45 try {
46 await writeFile(path, content, { encoding: 'utf8', flag: 'wx', mode })
47 return true
48 } catch (e) {
49 if (getErrnoCode(e) === 'EEXIST') return false
50 throw e
51 }
52}
53
54/**
55 * Ensure the local package environment is set up

Callers 1

Calls 1

getErrnoCodeFunction · 0.85

Tested by

no test coverage detected