feat(omo-codex): batch 79 (8 files)

This commit is contained in:
YeonGyu-Kim
2026-05-30 19:12:13 +09:00
parent a6193606ad
commit 08e0a989ea
8 changed files with 509 additions and 0 deletions
@@ -0,0 +1,22 @@
import { renameSync, unlinkSync, writeFileSync } from "node:fs"
export function writeFileAtomically(filePath: string, content: string): void {
const tempPath = `${filePath}.tmp`
writeFileSync(tempPath, content, "utf-8")
try {
renameSync(tempPath, filePath)
} catch (error) {
const isPermissionError =
error instanceof Error &&
(error.message.includes("EPERM") || error.message.includes("EACCES"))
if (process.platform === "win32" && isPermissionError) {
unlinkSync(filePath)
renameSync(tempPath, filePath)
return
}
throw error
}
}