import fs from "fs"; /** * Writes data as formatted JSON to a file path. * Safely catches and re-throws file system errors. */ export function writeJsonFile(filePath: string, data: unknown): void { const tempPath = `${filePath}.tmp`; fs.writeFileSync(tempPath, JSON.stringify(data, null, 2), "utf-8"); fs.renameSync(tempPath, filePath); }