MCPcopy Index your code
hub / github.com/tiann/hapi / writeFileSafe

Function writeFileSafe

cli/src/opencode/utils/opencodeConfig.ts:71–81  ·  view source on GitHub ↗

* Write file only if content has changed.

(filePath: string, content: string)

Source from the content-addressed store, hash-verified

69 * Write file only if content has changed.
70 */
71function writeFileSafe(filePath: string, content: string): void {
72 try {
73 const current = readFileSync(filePath, 'utf-8');
74 if (current === content) {
75 return;
76 }
77 } catch {
78 // Ignore missing or unreadable file
79 }
80 writeFileSync(filePath, content, 'utf-8');
81}

Callers 1

ensureOpencodeConfigFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected