writeWhole
uses node:fs
Write a file whole: beside it first, then moved into place, so a reader finds the old one or the new one.
import { ownId } from "#codebase/tcmts/cli/web"; import fs from "node:fs"; export function writeWhole(file: string, data: string | Uint8Array) { const part = `${file}.${ownId()}`; fs.writeFileSync(part, data); fs.renameSync(part, file); }