diff --git a/CHANGELOG.md b/CHANGELOG.md index 61364df3..ee5ac510 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +### 2.3.2 | 2022-05-11 + +- Fix download method not working for the vscode cli. + ### 2.3.1 | 2022-04-04 - Gracefully kill VS Code if SIGINT is received diff --git a/lib/download.ts b/lib/download.ts index 1532e259..08870af2 100644 --- a/lib/download.ts +++ b/lib/download.ts @@ -258,8 +258,8 @@ async function downloadVSCodeArchive(options: DownloadOptions) { async function unzipVSCode( reporter: ProgressReporter, extractDir: string, - extractSync: boolean, stream: Readable, + platform: DownloadPlatform, format: 'zip' | 'tgz' ) { const stagingFile = path.join(tmpdir(), `vscode-test-${Date.now()}.zip`); @@ -306,7 +306,9 @@ async function unzipVSCode( fs.mkdirSync(extractDir); } - await spawnDecompressorChild('tar', ['-xzf', '-', '--strip-components=1', '-C', extractDir], stream); + // The CLI is a singular binary that doesn't have a wrapper component to remove + const s = platform.includes('cli-') ? 0 : 1; + await spawnDecompressorChild('tar', ['-xzf', '-', `--strip-components=${s}`, '-C', extractDir], stream); } } @@ -340,7 +342,6 @@ export async function download(options: Partial = {}): Promise< platform = systemDefaultPlatform, cachePath = defaultCachePath, reporter = new ConsoleReporter(process.stdout.isTTY), - extractSync = false, timeout = 15_000, } = options; @@ -421,7 +422,7 @@ export async function download(options: Partial = {}): Promise< }); // important! do not put anything async here, since unzipVSCode will need // to start consuming the stream immediately. - await unzipVSCode(reporter, downloadStaging, extractSync, stream, format); + await unzipVSCode(reporter, downloadStaging, stream, platform, format); await fs.promises.rename(downloadStaging, downloadedPath); reporter.report({ stage: ProgressReportStage.NewInstallComplete, downloadedPath }); diff --git a/package.json b/package.json index 5438b217..7c90dfd0 100644 --- a/package.json +++ b/package.json @@ -1,10 +1,10 @@ { "name": "@vscode/test-electron", - "version": "2.3.1", + "version": "2.3.2", "scripts": { "compile": "tsc -p ./", "watch": "tsc -w -p ./", - "prepublish": "tsc -p ./", + "prepack": "tsc -p ./", "fmt": "prettier --write \"lib/**/*.ts\" \"*.md\"", "test": "eslint lib --ext ts && vitest && tsc --noEmit", "prepare": "husky install"