import { readdir } from "fs-extra"; import { resolve } from "path"; // https://stackoverflow.com/a/45130990 export async function* getFiles(dir: string): AsyncGenerator { const dirents = await readdir(dir, { withFileTypes: true }); for (const dirent of dirents) { const res = resolve(dir, dirent.name); if (dirent.isDirectory()) { yield* getFiles(res); } else { yield res; } } }