зеркало из https://github.com/electron/electron.git
15 строки
435 B
TypeScript
15 строки
435 B
TypeScript
import { once } from 'events';
|
|
import * as walkdir from 'walkdir';
|
|
|
|
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;
|
|
}
|