test: use async helpers to simplify tests (#37314)
test: use async helpers to simplify the tests Co-authored-by: Milan Burda <miburda@microsoft.com>
This commit is contained in:
parent
0de1012280
commit
ee87438d28
9 changed files with 22 additions and 21 deletions
|
@ -1,4 +1,5 @@
|
|||
import * as walkdir from 'walkdir';
|
||||
import { emittedOnce } from './lib/events-helpers';
|
||||
|
||||
export async function getFiles (directoryPath: string, { filter = null }: {filter?: ((file: string) => boolean) | null} = {}) {
|
||||
const files: string[] = [];
|
||||
|
@ -8,6 +9,6 @@ export async function getFiles (directoryPath: string, { filter = null }: {filte
|
|||
walker.on('file', (file) => {
|
||||
if (!filter || filter(file)) { files.push(file); }
|
||||
});
|
||||
await new Promise((resolve) => walker.on('end', resolve));
|
||||
await emittedOnce(walker, 'end');
|
||||
return files;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue