From a8e77126e8b65b53e4eda56c08203ecd62682872 Mon Sep 17 00:00:00 2001 From: Richard Hansen Date: Sun, 9 May 2021 16:41:59 -0400 Subject: [PATCH] tests: Combine `.map().filter().map()` into single `.map()` --- src/node/hooks/express/tests.js | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/node/hooks/express/tests.js b/src/node/hooks/express/tests.js index 5f40a67f0..0dc2bb8ec 100644 --- a/src/node/hooks/express/tests.js +++ b/src/node/hooks/express/tests.js @@ -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; };