Files
ame/scripts/utils/path.ts
2023-07-28 22:25:29 +03:00

14 lines
374 B
TypeScript

import { join } from "path";
import { readdir } from "fs/promises";
// Walks a directory tree starting from path.
export async function* walk(path: string): AsyncGenerator<string> {
for (const entry of await readdir(path, { withFileTypes: true })) {
if (entry.isDirectory()) {
yield* walk(join(path, entry.name));
} else {
yield join(path, entry.name);
}
}
}