From e8eb68bf245b81be7f81b8cb17fc9809e98f0e76 Mon Sep 17 00:00:00 2001 From: GyDi Date: Sun, 23 Jul 2023 13:11:17 +0800 Subject: [PATCH] chore: fix check script --- scripts/check.mjs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/scripts/check.mjs b/scripts/check.mjs index f0604f3..094a4e4 100644 --- a/scripts/check.mjs +++ b/scripts/check.mjs @@ -123,8 +123,9 @@ async function resolveSidecar(binInfo) { await fs.mkdirp(tempDir); try { - if (!(await fs.pathExists(tempZip))) + if (!(await fs.pathExists(tempZip))) { await downloadFile(downloadURL, tempZip); + } if (zipFile.endsWith(".zip")) { const zip = new AdmZip(tempZip); @@ -140,7 +141,7 @@ async function resolveSidecar(binInfo) { const writeStream = fs.createWriteStream(sidecarPath); await new Promise((resolve, reject) => { const onError = (error) => { - console.error(`[ERROR]: "${name}" gz failed`, error.message); + console.error(`[ERROR]: "${name}" gz failed:`, error.message); reject(error); }; readStream @@ -156,6 +157,8 @@ async function resolveSidecar(binInfo) { }); } } catch (err) { + // 需要删除文件 + await fs.remove(sidecarPath); throw err; } finally { // delete temp dir @@ -318,7 +321,8 @@ async function runTask() { await task.func(); break; } catch (err) { - console.error(`[ERROR]: task::${task.name} try ${i} == `, err.message); + console.error(`[ERROR]: task::${task.name} try ${i} ==`, err.message); + if (i === task.retry - 1) throw err; } } return runTask();