Files
WRNexusJS/packages/cli/src/write-generated.ts
T
Clintchiz a3ddd39b7b
Quality / quality (ubuntu-latest) (push) Failing after 14m38s
Quality / quality (windows-latest) (push) Canceled after 0s
feat: centralize application framework primitives
2026-08-22 23:07:46 +05:30

12 lines
470 B
TypeScript

import { existsSync, readFileSync, writeFileSync } from "node:fs";
/** Write generated UTF-8 output only when bytes changed, preserving mtimes on no-op builds. */
export function writeGeneratedFile(path: string, content: string): boolean {
const normalized = content.replace(/\r\n/g, "\n");
if (existsSync(path) && readFileSync(path, "utf8").replace(/\r\n/g, "\n") === normalized) {
return false;
}
writeFileSync(path, normalized, "utf8");
return true;
}