refactor(omo-codex): sync telemetry component sources

This commit is contained in:
YeonGyu-Kim
2026-05-26 17:40:46 +09:00
parent b164cb94be
commit f77338b4a2
9 changed files with 307 additions and 106 deletions
@@ -1,21 +1,22 @@
import { renameSync, unlinkSync, writeFileSync } from "node:fs";
import { renameSync, unlinkSync, writeFileSync } from "node:fs"
export function writeFileAtomically(filePath: string, content: string): void {
const tempPath = `${filePath}.tmp`;
writeFileSync(tempPath, content, "utf-8");
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"));
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;
}
if (process.platform === "win32" && isPermissionError) {
unlinkSync(filePath)
renameSync(tempPath, filePath)
return
}
throw error;
}
throw error
}
}