Skip to content

Commit

Permalink
Merge pull request #217 from microsoft/fix-cli-download
Browse files Browse the repository at this point in the history
fix: download cli correctly for linux
  • Loading branch information
connor4312 authored May 11, 2023
2 parents 7f7e8fd + e882651 commit dfda603
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
9 changes: 5 additions & 4 deletions lib/download.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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`);
Expand Down Expand Up @@ -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);
}
}

Expand Down Expand Up @@ -340,7 +342,6 @@ export async function download(options: Partial<DownloadOptions> = {}): Promise<
platform = systemDefaultPlatform,
cachePath = defaultCachePath,
reporter = new ConsoleReporter(process.stdout.isTTY),
extractSync = false,
timeout = 15_000,
} = options;

Expand Down Expand Up @@ -421,7 +422,7 @@ export async function download(options: Partial<DownloadOptions> = {}): 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 });
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -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"
Expand Down

0 comments on commit dfda603

Please sign in to comment.