feat: centralize application framework primitives
This commit is contained in:
@@ -0,0 +1,11 @@
|
||||
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;
|
||||
}
|
||||
Reference in New Issue
Block a user