@vscode/test-electron
Advanced tools
Comparing version 2.1.4 to 2.1.5
# Changelog | ||
### 2.1.4 | 2022-06-27 | ||
- Automatically retry if VS Code download fails | ||
### 2.1.4 | 2022-06-10 | ||
@@ -4,0 +8,0 @@ |
@@ -21,2 +21,3 @@ "use strict"; | ||
const vscodeStableReleasesAPI = `https://update.code.visualstudio.com/api/releases/stable`; | ||
const DOWNLOAD_ATTEMPTS = 3; | ||
async function fetchLatestStableVersion() { | ||
@@ -194,11 +195,20 @@ const versions = await request.getJSON(vscodeStableReleasesAPI); | ||
} | ||
try { | ||
const { stream, format } = await downloadVSCodeArchive({ version, platform, cachePath, reporter }); | ||
await unzipVSCode(reporter, downloadedPath, extractSync, stream, format); | ||
reporter.report({ stage: progress_1.ProgressReportStage.NewInstallComplete, downloadedPath }); | ||
for (let i = 0;; i++) { | ||
try { | ||
const { stream, format } = await downloadVSCodeArchive({ version, platform, cachePath, reporter }); | ||
await unzipVSCode(reporter, downloadedPath, extractSync, stream, format); | ||
reporter.report({ stage: progress_1.ProgressReportStage.NewInstallComplete, downloadedPath }); | ||
break; | ||
} | ||
catch (error) { | ||
if (i++ < DOWNLOAD_ATTEMPTS) { | ||
reporter.report({ stage: progress_1.ProgressReportStage.Retrying, attempt: i, error: error, totalAttempts: DOWNLOAD_ATTEMPTS }); | ||
} | ||
else { | ||
reporter.error(error); | ||
throw Error(`Failed to download and unzip VS Code ${version}`); | ||
} | ||
} | ||
} | ||
catch (err) { | ||
reporter.error(err); | ||
throw Error(`Failed to download and unzip VS Code ${version}`); | ||
} | ||
reporter.report({ stage: progress_1.ProgressReportStage.NewInstallComplete, downloadedPath }); | ||
if (version === 'insiders') { | ||
@@ -205,0 +215,0 @@ return Promise.resolve(util_2.insidersDownloadDirToExecutablePath(downloadedPath, platform)); |
@@ -19,2 +19,4 @@ /** Stages of progress while downloading VS Code */ | ||
ExtractingSynchonrously = "extractingSynchonrously", | ||
/** Fired when the download fails and a retry will be attempted */ | ||
Retrying = "retrying", | ||
/** Fired after folder is downloaded and unzipped */ | ||
@@ -49,2 +51,7 @@ NewInstallComplete = "newInstallComplete" | ||
} | { | ||
stage: ProgressReportStage.Retrying; | ||
error: Error; | ||
attempt: number; | ||
totalAttempts: number; | ||
} | { | ||
stage: ProgressReportStage.ExtractingSynchonrously; | ||
@@ -72,3 +79,4 @@ } | { | ||
error(err: unknown): void; | ||
private flushDownloadReport; | ||
private reportDownload; | ||
} |
@@ -27,2 +27,4 @@ "use strict"; | ||
ProgressReportStage["ExtractingSynchonrously"] = "extractingSynchonrously"; | ||
/** Fired when the download fails and a retry will be attempted */ | ||
ProgressReportStage["Retrying"] = "retrying"; | ||
/** Fired after folder is downloaded and unzipped */ | ||
@@ -59,5 +61,2 @@ ProgressReportStage["NewInstallComplete"] = "newInstallComplete"; | ||
break; | ||
case ProgressReportStage.NewInstallComplete: | ||
console.log(`Downloaded VS Code ${this.version} into ${report.downloadedPath}`); | ||
break; | ||
case ProgressReportStage.ResolvingCDNLocation: | ||
@@ -77,9 +76,8 @@ console.log(`Downloading VS Code ${this.version} from ${report.url}`); | ||
break; | ||
case ProgressReportStage.Retrying: | ||
this.flushDownloadReport(); | ||
console.log(`Error downloading, retrying (attempt ${report.attempt} of ${report.totalAttempts}): ${report.error.message}`); | ||
break; | ||
case ProgressReportStage.NewInstallComplete: | ||
if (this.downloadReport) { | ||
clearTimeout(this.downloadReport.timeout); | ||
} | ||
if (this.showDownloadProgress) { | ||
console.log(''); | ||
} | ||
this.flushDownloadReport(); | ||
console.log(`Downloaded VS Code into ${report.downloadedPath}`); | ||
@@ -92,2 +90,8 @@ break; | ||
} | ||
flushDownloadReport() { | ||
if (this.showDownloadProgress) { | ||
this.reportDownload(); | ||
console.log(''); | ||
} | ||
} | ||
reportDownload() { | ||
@@ -94,0 +98,0 @@ if (!this.downloadReport) { |
{ | ||
"name": "@vscode/test-electron", | ||
"version": "2.1.4", | ||
"version": "2.1.5", | ||
"scripts": { | ||
@@ -5,0 +5,0 @@ "compile": "tsc -p ./", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
62569
1018