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

Function writeIfMissing

src/utils/localInstaller.ts:38–50  ·  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

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

Callers 1

Calls 1

getErrnoCodeFunction · 0.85

Tested by

no test coverage detected