MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / atomicWriteFileSync

Function atomicWriteFileSync

src/installer/targets/shared.ts:81–94  ·  view source on GitHub ↗
(filePath: string, content: string)

Source from the content-addressed store, hash-verified

79 * file is cleaned up on rename failure.
80 */
81export function atomicWriteFileSync(filePath: string, content: string): void {
82 const dir = path.dirname(filePath);
83 if (!fs.existsSync(dir)) {
84 fs.mkdirSync(dir, { recursive: true });
85 }
86 const tmpPath = filePath + '.tmp.' + process.pid;
87 try {
88 fs.writeFileSync(tmpPath, content);
89 fs.renameSync(tmpPath, filePath);
90 } catch (err) {
91 try { fs.unlinkSync(tmpPath); } catch { /* ignore */ }
92 throw err;
93 }
94}
95
96/**
97 * Atomic JSON write. Trailing newline matches the convention every

Callers 10

uninstallMethod · 0.90
writeMcpEntryFunction · 0.90
uninstallMethod · 0.90
writeHermesConfigFunction · 0.90
writeMcpEntryFunction · 0.90
removeMcpEntryAtFunction · 0.90
removeRulesEntryFunction · 0.90
writeJsonFileFunction · 0.85
removeMarkedSectionFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected