nit: move to await try/catch

This commit is contained in:
weboko 2022-12-08 18:34:38 +01:00 committed by weboko
parent 440e297c60
commit f846d7cec3
No known key found for this signature in database
1 changed files with 12 additions and 11 deletions

View File

@ -12,23 +12,24 @@ async function run() {
console.log("Started copying supported Waku examples."); 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 resolvedPath = path.resolve(__dirname, relativePath);
const destinationPath = path.resolve(examplesFolder, name); 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}`); console.error(`Failed to copy example ${name} to ${destinationPath} with ${error.message}`);
throw Error(error.message); throw Error(error.message);
}); }
}); });
await Promise.all(copyPromises) try {
.then(() => { await Promise.all(copyPromises);
console.log("Finished copying examples."); console.log("Finished copying examples.");
}) } catch (error) {
.catch((error) => { console.error("Failed to copy examples due to " + error.message);
console.error("Failed to copy examples due to " + error.message); }
});
} }
function nodeModulesFiler(src) { function nodeModulesFiler(src) {