Files
vscode-codeql/extensions/ql-vscode/scripts/util/files.ts
Elena Tanasoiu 670c863f3f Autofix import/no-namespace
I'm leaving the rule turned off as it still has 100+ offenses that aren't
autofixable.
2022-12-01 09:10:44 +00:00

16 lines
422 B
TypeScript

import { readdir } from "fs-extra";
import { resolve } from "path";
// https://stackoverflow.com/a/45130990
export async function* getFiles(dir: string): AsyncGenerator<string> {
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;
}
}
}