tests: Combine `.map().filter().map()` into single `.map()`

pull/5050/head
Richard Hansen 2021-05-09 16:41:59 -04:00
parent 2414203434
commit a8e77126e8
1 changed files with 8 additions and 9 deletions

View File

@ -61,15 +61,14 @@ const getPluginTests = async (callback) => {
const pluginSpecs = [];
const plugins = await fsp.readdir(moduleDir);
await Promise.all(plugins
.map((plugin) => [plugin, moduleDir + plugin + specPath])
.filter(([plugin, specDir]) => fs.existsSync(specDir)) // check plugin exists
.map(async ([plugin, specDir]) => {
const specFiles = await fsp.readdir(specDir);
for (const spec of specFiles) {
pluginSpecs.push(staticDir + plugin + specPath + spec);
}
}));
await Promise.all(plugins.map(async (plugin) => {
const specDir = moduleDir + plugin + specPath;
if (!fs.existsSync(specDir)) return;
const specFiles = await fsp.readdir(specDir);
for (const spec of specFiles) {
pluginSpecs.push(staticDir + plugin + specPath + spec);
}
}));
return pluginSpecs;
};