From 10ee4155aa50ae4cbc98a28733037218f930847e Mon Sep 17 00:00:00 2001 From: RrOrange <542716863@qq.com> Date: Tue, 11 Apr 2023 21:29:54 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=8E=88=20perf:=20=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E6=B8=85=E7=90=86=E6=96=87=E4=BB=B6=E6=80=A7=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- utils/file.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/utils/file.js b/utils/file.js index 9381f80..6f08e2b 100644 --- a/utils/file.js +++ b/utils/file.js @@ -43,20 +43,20 @@ async function mkdirIfNotExists(dir) { async function deleteFolderRecursive(folderPath) { try { const files = await fs.promises.readdir(folderPath); - const filePromises = files.map(async (file) => { + const actions = files.map(async (file) => { const curPath = path.join(folderPath, file); - const stat = await fs.promises.lstat(curPath); + const stat = await fs.promises.lstat(curPath); if (stat.isDirectory()) { // recurse - await deleteFolderRecursive(curPath); + return deleteFolderRecursive(curPath); } else { // delete file - await fs.promises.unlink(curPath); + return fs.promises.unlink(curPath); } }); - await Promise.all(filePromises); + await Promise.allSettled(actions); await fs.promises.rmdir(folderPath); return files.length; } catch (error) {