MCPcopy Create free account
hub / github.com/cifertech/DisplayKit / main

Function main

scripts/generate_icon_manifests.mjs:49–79  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

47}
48
49async function main() {
50 // Ensure icons dir exists
51 await fs.access(iconsDir);
52
53 const files = sortFiles(await walk(iconsDir, iconsDir));
54 const manifest = {
55 version: 1,
56 basePath: "icons/",
57 generatedAt: new Date().toISOString(),
58 files
59 };
60
61 const jsonPath = path.join(iconsDir, "manifest.json");
62 const jsPath = path.join(iconsDir, "manifest.js");
63
64 const json = JSON.stringify(manifest, null, 2) + "\n";
65 const js =
66 `// Auto-generated icon manifest for DisplayKit.\n` +
67 `// This file exists to support running DisplayKit via file:// (where fetch() to local JSON is often blocked).\n` +
68 `// When hosted (http/https), the app can also load icons/manifest.json.\n` +
69 `window.DISPLAYKIT_ICON_MANIFEST = ${JSON.stringify(manifest, null, 2)};\n`;
70
71 const changedJson = await writeIfChanged(jsonPath, json);
72 const changedJs = await writeIfChanged(jsPath, js);
73
74 if (changedJson || changedJs) {
75 console.log("Updated icon manifests.");
76 } else {
77 console.log("Icon manifests already up to date.");
78 }
79}
80
81main().catch((err) => {
82 console.error(err);

Callers 1

Calls 3

sortFilesFunction · 0.85
walkFunction · 0.85
writeIfChangedFunction · 0.85

Tested by

no test coverage detected