Fable clean up

This commit is contained in:
Andras Schmelczer 2026-06-11 21:35:45 +01:00
parent 3441a7e4af
commit 4ce8a4f41d
46 changed files with 642 additions and 911 deletions

23
scripts/lib/walk.mjs Normal file
View file

@ -0,0 +1,23 @@
import { readdir, stat } from 'node:fs/promises';
import path from 'node:path';
// Recursively lists every file under entryPath. A path that is itself a file
// resolves to a single-element list, so callers can mix files and directories.
export async function walk(entryPath) {
const entryStat = await stat(entryPath);
if (entryStat.isFile()) return [entryPath];
const entries = await readdir(entryPath, { withFileTypes: true });
const files = [];
for (const entry of entries) {
const fullPath = path.join(entryPath, entry.name);
if (entry.isDirectory()) {
files.push(...(await walk(fullPath)));
} else {
files.push(fullPath);
}
}
return files;
}