Added a badge to display the monthly ramp

This commit is contained in:
2026-09-23 23:24:31 -03:00
parent 3ef0d2aafd
commit b92d75f558
11 changed files with 229 additions and 21 deletions

20
scripts/write-output.cjs Normal file
View File

@@ -0,0 +1,20 @@
const fs = require("node:fs/promises");
const { randomUUID } = require("node:crypto");
async function writeOutput(file, contents, io = fs) {
try {
if (await io.readFile(file, "utf8") === contents) return;
} catch (error) {
if (error.code !== "ENOENT") throw error;
}
// Replace a complete file; never remove or truncate a script the browser may load.
const temporary = `${file}.${randomUUID()}.tmp`;
try {
await io.writeFile(temporary, contents, { encoding: "utf8", flag: "wx" });
await io.rename(temporary, file);
} finally {
await io.rm(temporary, { force: true });
}
}
module.exports = { writeOutput };