flag cleanup

This commit is contained in:
tree🌴 2024-02-21 12:36:48 +01:00
parent cdddf29387
commit a7550d5115
2 changed files with 14 additions and 0 deletions

View file

@ -6,6 +6,7 @@
"dev": "astro dev", "dev": "astro dev",
"start": "astro dev", "start": "astro dev",
"build": "astro build", "build": "astro build",
"cleanup-flags": "deno run --allow-all utils/cleanup-flags.js",
"preview": "astro preview", "preview": "astro preview",
"astro": "astro", "astro": "astro",
"core": "deno run --allow-all utils/core.js", "core": "deno run --allow-all utils/core.js",

13
utils/cleanup-flags.js Normal file
View file

@ -0,0 +1,13 @@
import { join } from "https://deno.land/std@0.216.0/path/join.ts";
const src = JSON.parse(await Deno.readTextFile("./src/core.json"));
const usedFlags = [...new Set(src.events.map((e) => e.country + ".svg"))];
console.log(usedFlags);
const flagDir = "./dist/flags";
for await (const f of Deno.readDir(flagDir)) {
if (f.isDirectory || !usedFlags.includes(f.name)) {
await Deno.remove(join(flagDir, f.name), { recursive: true });
}
}