test: refactor how spec files are collected (#23774)
This commit is contained in:
parent
5d88d0ee74
commit
3a7775fa73
3 changed files with 87 additions and 82 deletions
15
spec/static/get-files.js
Normal file
15
spec/static/get-files.js
Normal 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;
|
Loading…
Add table
Add a link
Reference in a new issue