electron/spec/get-files.ts
Samuel Attard ba6d9291d2
build: add import/order eslint rule (#44108)
build: add import/order eslint rule (#44085)

* build: add import/order eslint rule

* chore: run lint:js --fix
2024-10-03 15:21:54 -07:00

15 lines
441 B
TypeScript

import * as walkdir from 'walkdir';
import { once } from 'node:events';
export async function getFiles (directoryPath: string, { filter = null }: {filter?: ((file: string) => boolean) | null} = {}) {
const files: string[] = [];
const walker = walkdir(directoryPath, {
no_recurse: true
});
walker.on('file', (file) => {
if (!filter || filter(file)) { files.push(file); }
});
await once(walker, 'end');
return files;
}