nit: move to await try/catch
This commit is contained in:
parent
440e297c60
commit
f846d7cec3
|
@ -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) {
|
||||||
|
|
Loading…
Reference in New Issue