| 13 | } |
| 14 | |
| 15 | async function walk(dir, baseDir) { |
| 16 | const entries = await fs.readdir(dir, { withFileTypes: true }); |
| 17 | const out = []; |
| 18 | for (const e of entries) { |
| 19 | const full = path.join(dir, e.name); |
| 20 | if (e.isDirectory()) { |
| 21 | // Skip node_modules or dot dirs if any |
| 22 | if (e.name.startsWith(".")) continue; |
| 23 | out.push(...(await walk(full, baseDir))); |
| 24 | } else if (e.isFile() && isPng(e.name)) { |
| 25 | const rel = path.relative(baseDir, full).split(path.sep).join("/"); |
| 26 | // Only include files under icons/<size>/... |
| 27 | out.push(rel); |
| 28 | } |
| 29 | } |
| 30 | return out; |
| 31 | } |
| 32 | |
| 33 | function sortFiles(files) { |
| 34 | return [...files].sort((a, b) => a.localeCompare(b, "en")); |