From f00f9aa14cb87758e57faa9b45f8d3cbe03033ca Mon Sep 17 00:00:00 2001 From: Richard Hansen Date: Sun, 9 May 2021 16:30:53 -0400 Subject: [PATCH] tests: Avoid `.then()` inside `async` functions --- src/node/hooks/express/tests.js | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/node/hooks/express/tests.js b/src/node/hooks/express/tests.js index 247c8fb97..c2557f799 100644 --- a/src/node/hooks/express/tests.js +++ b/src/node/hooks/express/tests.js @@ -84,15 +84,16 @@ exports.getPluginTests = async (callback) => { const pluginSpecs = []; const plugins = await readdir(moduleDir); - const promises = plugins + await Promise.all(plugins .map((plugin) => [plugin, moduleDir + plugin + specPath]) .filter(([plugin, specDir]) => fs.existsSync(specDir)) // check plugin exists - .map(async ([plugin, specDir]) => await readdir(specDir) - .then((specFiles) => specFiles.map((spec) => { - pluginSpecs.push(staticDir + plugin + specPath + spec); - }))); - - return await Promise.all(promises).then(() => pluginSpecs); + .map(async ([plugin, specDir]) => { + const specFiles = await readdir(specDir); + return specFiles.map((spec) => { + pluginSpecs.push(staticDir + plugin + specPath + spec); + }); + })); + return pluginSpecs; }; exports.getCoreTests = async () => await readdir('src/tests/frontend/specs');