diff --git a/package.json b/package.json index f6e28e7..122f65b 100644 --- a/package.json +++ b/package.json @@ -6,6 +6,7 @@ "dev": "astro dev", "start": "astro dev", "build": "astro build", + "cleanup-flags": "deno run --allow-all utils/cleanup-flags.js", "preview": "astro preview", "astro": "astro", "core": "deno run --allow-all utils/core.js", diff --git a/utils/cleanup-flags.js b/utils/cleanup-flags.js new file mode 100644 index 0000000..ea8b2a6 --- /dev/null +++ b/utils/cleanup-flags.js @@ -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 }); + } +}