Skip to content

Commit cb1ccdd

Browse files
veilletteclaude
andcommitted
chore(scripts): sync generate-icons.ts from SceneryStackTemplate
Flags parsed with util.parseArgs and import.meta.dirname replaces the fileURLToPath dance (template c6abe65). Unknown flags now fail loudly. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 124366e commit cb1ccdd

1 file changed

Lines changed: 12 additions & 5 deletions

File tree

‎scripts/generate-icons.ts‎

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,19 @@
1818
*/
1919

2020
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
21-
import { dirname, resolve } from "node:path";
22-
import { fileURLToPath } from "node:url";
21+
import { resolve } from "node:path";
22+
import { parseArgs } from "node:util";
2323
import pngToIco from "png-to-ico";
2424
import sharp from "sharp";
2525

26-
const here = dirname(fileURLToPath(import.meta.url));
26+
const { values: flags } = parseArgs({
27+
options: {
28+
"screenshots-from-assets": { type: "boolean", default: false },
29+
"placeholder-screenshots": { type: "boolean", default: false },
30+
},
31+
});
32+
33+
const here = import.meta.dirname;
2734
const publicDir = resolve(here, "..", "public");
2835
const svg = readFileSync(resolve(publicDir, "icons", "icon.svg"));
2936

@@ -85,8 +92,8 @@ async function writeScreenshotFrom(source: string, width: number, height: number
8592
}
8693

8794
const capture = resolve(here, "..", "assets", "screenshot.png");
88-
const fromAssets = process.argv.includes("--screenshots-from-assets");
89-
const overwriteScreenshots = process.argv.includes("--placeholder-screenshots");
95+
const fromAssets = flags["screenshots-from-assets"];
96+
const overwriteScreenshots = flags["placeholder-screenshots"];
9097
if (fromAssets && !existsSync(capture)) {
9198
throw new Error("--screenshots-from-assets needs assets/screenshot.png (Baton/scripts/generate-screenshots.sh)");
9299
}

0 commit comments

Comments
 (0)