Skip to content

Commit

Permalink
fix: handling win installer exit code
Browse files Browse the repository at this point in the history
Signed-off-by: Yevhen Vydolob <[email protected]>
  • Loading branch information
evidolob committed Mar 14, 2023
1 parent 2d28d45 commit fc80969
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
8 changes: 2 additions & 6 deletions src/install/base-install.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ export abstract class BaseInstaller implements Installer {
abstract getPreflightChecks(): extensionApi.InstallCheck[];

async downloadSha(installerUrl: string, fileName: string): Promise<string> {
console.info('Download SHA sums...');
const shaSumUrl = installerUrl.substring(0, installerUrl.lastIndexOf('/')) + '/sha256sum.txt';
const shaSumContentResponse = await got.get(shaSumUrl);

Expand All @@ -104,15 +103,12 @@ export abstract class BaseInstaller implements Installer {

async downloadCrcInstaller(installerUrl: string, destinationPath: string, fileSha: string): Promise<void> {
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;
}
});
Expand All @@ -129,7 +125,7 @@ export abstract class BaseInstaller implements Installer {

protected async downloadAndCheckInstaller(installerUrl: string, installerFileName: string): Promise<string> {
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');
Expand Down
2 changes: 2 additions & 0 deletions src/install/win-install.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit fc80969

Please sign in to comment.