web/utils/cleanup-flags.js

14 lines
422 B
JavaScript
Raw Normal View History

2024-09-09 00:31:17 +02:00
import { join } from "jsr:@std/path@0.224.0";
2024-02-21 12:36:48 +01:00
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 });
}
}