From 604c59438e53e7a649ff838bca38b777ad6cda56 Mon Sep 17 00:00:00 2001 From: Yevhen Vydolob Date: Mon, 13 Mar 2023 14:34:54 +0200 Subject: [PATCH] fix: handling win installer exit code Signed-off-by: Yevhen Vydolob --- src/install/base-install.ts | 8 ++------ src/install/win-install.ts | 2 ++ 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/install/base-install.ts b/src/install/base-install.ts index 3571ee3..b178cee 100644 --- a/src/install/base-install.ts +++ b/src/install/base-install.ts @@ -80,7 +80,6 @@ export abstract class BaseInstaller implements Installer { abstract getPreflightChecks(): extensionApi.InstallCheck[]; async downloadSha(installerUrl: string, fileName: string): Promise { - console.info('Download SHA sums...'); const shaSumUrl = installerUrl.substring(0, installerUrl.lastIndexOf('/')) + '/sha256sum.txt'; const shaSumContentResponse = await got.get(shaSumUrl); @@ -104,15 +103,12 @@ export abstract class BaseInstaller implements Installer { async downloadCrcInstaller(installerUrl: string, destinationPath: string, fileSha: string): Promise { let lastProgressStr = ''; - - this.statusBarItem.text = 'Downloading'; const downloadStream = got.stream(installerUrl); downloadStream.on('downloadProgress', (progress) => { - const progressStr = /* progress.transferred + ' of ' + progress.total + ' ' + */Math.round(progress.percent * 100) + '%'; + const progressStr = /* progress.transferred + ' of ' + progress.total + ' ' + */Math.round(progress.percent * 100) + '%'; if(lastProgressStr !== progressStr) { - //TODO: show progress on UI! this.statusBarItem.text = 'Downloading: ' + progressStr; } }); @@ -129,7 +125,7 @@ export abstract class BaseInstaller implements Installer { protected async downloadAndCheckInstaller(installerUrl: string, installerFileName: string): Promise { this.createStatusBar(); - this.statusBarItem.text = 'Downloading SHA...' + this.statusBarItem.text = 'Downloading: 0%'; const sha = await this.downloadSha(installerUrl, installerFileName); const installerFolder = path.resolve(os.tmpdir(), 'crc-extension'); diff --git a/src/install/win-install.ts b/src/install/win-install.ts index d818cdf..1cfa7fd 100644 --- a/src/install/win-install.ts +++ b/src/install/win-install.ts @@ -52,6 +52,8 @@ export class WinInstall extends BaseInstaller { 'OK', ); return true; + } else if(runResult.exitCode === 1602) { // user cancel installation + return false; } else { throw new Error(runResult.stdErr); }