test: refactor how spec files are collected (#23774)

This commit is contained in:
Alexey Kuzmin 2020-05-28 00:21:02 +02:00 committed by GitHub
parent 5d88d0ee74
commit 3a7775fa73
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 87 additions and 82 deletions

15
spec/static/get-files.js Normal file
View file

@ -0,0 +1,15 @@
async function getFiles (directoryPath, { filter = null } = {}) {
const files = [];
const walker = require('walkdir').walk(directoryPath, {
no_recurse: true
});
walker.on('file', (file) => {
if (!filter || filter(file)) {
files.push(file);
}
});
await new Promise((resolve) => walker.on('end', resolve));
return files;
}
module.exports = getFiles;