Gateway: sync runtime post-build artifacts

This commit is contained in:
Gustavo Madeira Santana
2026-03-15 20:44:03 +00:00
parent b795ba1d02
commit 4fb0160309
8 changed files with 376 additions and 43 deletions

View File

@@ -0,0 +1,26 @@
import fs from "node:fs";
import { dirname } from "node:path";
export function writeTextFileIfChanged(filePath, contents) {
const next = String(contents);
try {
const current = fs.readFileSync(filePath, "utf8");
if (current === next) {
return false;
}
} catch {
// Write the file when it does not exist or cannot be read.
}
fs.mkdirSync(dirname(filePath), { recursive: true });
fs.writeFileSync(filePath, next, "utf8");
return true;
}
export function removeFileIfExists(filePath) {
try {
fs.rmSync(filePath, { force: true });
return true;
} catch {
return false;
}
}