Files
verify/frontend/node_modules/next/dist/esm/lib/fs/write-atomic.js
Mohamed Mathar Irfan ed6610d5d8 Initial project upload
2026-07-28 17:57:02 +05:30

18 lines
508 B
JavaScript

import { unlink, writeFile } from "fs/promises";
import { rename } from "./rename";
export async function writeFileAtomic(filePath, content) {
const tempPath = filePath + ".tmp." + Math.random().toString(36).slice(2);
try {
await writeFile(tempPath, content, "utf-8");
await rename(tempPath, filePath);
} catch (e) {
try {
await unlink(tempPath);
} catch {
// ignore
}
throw e;
}
}
//# sourceMappingURL=write-atomic.js.map