From 4f019a65d4d0dc0411424d079ba8bfc1a1670a6d Mon Sep 17 00:00:00 2001 From: Connor Peet Date: Thu, 11 May 2023 13:43:11 -0700 Subject: [PATCH 1/2] fix: download cli correctly for linux I'm using this package for some smoke tests involving the CLI. Slight tweak is necessary. --- CHANGELOG.md | 4 ++++ lib/download.ts | 9 +++++---- package.json | 2 +- 3 files changed, 10 insertions(+), 5 deletions(-) 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..cf0d5cd9 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "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" From e88265154dfcc19d5c979e1c18c5f837f923239f Mon Sep 17 00:00:00 2001 From: Connor Peet Date: Thu, 11 May 2023 13:43:53 -0700 Subject: [PATCH 2/2] 2.3.2 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index cf0d5cd9..7c90dfd0 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@vscode/test-electron", - "version": "2.3.1", + "version": "2.3.2", "scripts": { "compile": "tsc -p ./", "watch": "tsc -w -p ./",