From fd0334645b415b8be574d44256194f601227cb40 Mon Sep 17 00:00:00 2001 From: LisiurDay Date: Wed, 30 Jun 2021 20:26:49 +0800 Subject: [PATCH] fix: tauri init may failed with no error message. (fix #2079) (#2117) Co-authored-by: Lucas Nogueira --- .changes/throw-error-on-cli-download-failure.md | 5 +++++ tooling/cli.js/src/helpers/download-binary.ts | 5 ++++- 2 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 .changes/throw-error-on-cli-download-failure.md diff --git a/.changes/throw-error-on-cli-download-failure.md b/.changes/throw-error-on-cli-download-failure.md new file mode 100644 index 000000000..2258e72bd --- /dev/null +++ b/.changes/throw-error-on-cli-download-failure.md @@ -0,0 +1,5 @@ +--- +"cli.js": patch +--- + +Throw error on `cli.rs` download failure instead of silent exit. diff --git a/tooling/cli.js/src/helpers/download-binary.ts b/tooling/cli.js/src/helpers/download-binary.ts index 24fd5f87e..59fbf0252 100644 --- a/tooling/cli.js/src/helpers/download-binary.ts +++ b/tooling/cli.js/src/helpers/download-binary.ts @@ -40,7 +40,10 @@ async function downloadBinaryRelease( // TODO: Check hash of download // eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access, security/detect-non-literal-fs-filename await pipeline(got.stream(url), fs.createWriteStream(outPath)).catch((e) => { - removeDownloadedCliIfNeeded() + try { + // eslint-disable-next-line security/detect-non-literal-fs-filename + fs.unlinkSync(outPath) + } catch {} throw e }) // eslint-disable-next-line security/detect-object-injection