From f846d7cec39fe2c53e0de56b5ba01e74d4575e52 Mon Sep 17 00:00:00 2001 From: weboko Date: Thu, 8 Dec 2022 18:34:38 +0100 Subject: [PATCH] nit: move to await try/catch --- packages/create-waku-app/build.js | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/packages/create-waku-app/build.js b/packages/create-waku-app/build.js index 32327f1..5e7d272 100644 --- a/packages/create-waku-app/build.js +++ b/packages/create-waku-app/build.js @@ -12,23 +12,24 @@ async function run() { console.log("Started copying supported Waku examples."); - const copyPromises = supportedExamples.map(([name, relativePath]) => { + const copyPromises = supportedExamples.map(async ([name, relativePath]) => { const resolvedPath = path.resolve(__dirname, relativePath); const destinationPath = path.resolve(examplesFolder, name); - - return fs.copy(resolvedPath, destinationPath, { filter: nodeModulesFiler }).catch((error) => { + + try { + await fs.copy(resolvedPath, destinationPath, { filter: nodeModulesFiler }); + } catch (error) { console.error(`Failed to copy example ${name} to ${destinationPath} with ${error.message}`); throw Error(error.message); - }); + } }); - await Promise.all(copyPromises) - .then(() => { - console.log("Finished copying examples."); - }) - .catch((error) => { - console.error("Failed to copy examples due to " + error.message); - }); + try { + await Promise.all(copyPromises); + console.log("Finished copying examples."); + } catch (error) { + console.error("Failed to copy examples due to " + error.message); + } } function nodeModulesFiler(src) {