From a7550d51158187a561e64bc5ff9a95e467c70fcb Mon Sep 17 00:00:00 2001 From: tree Date: Wed, 21 Feb 2024 12:36:48 +0100 Subject: [PATCH] flag cleanup --- package.json | 1 + utils/cleanup-flags.js | 13 +++++++++++++ 2 files changed, 14 insertions(+) create mode 100644 utils/cleanup-flags.js 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 }); + } +}