Skip to content

Commit f69d296

Browse files
Use Expand-Archive on Windows to avoid incompatibility based on which type of tar you have on path (windows or bash/wsl)
1 parent b9486f7 commit f69d296

1 file changed

Lines changed: 14 additions & 2 deletions

File tree

nodejs/src/acquisition.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -259,10 +259,22 @@ async function downloadCli(
259259
}
260260
}
261261

262-
// tar is built-in on Windows 10+, macOS, and Linux and handles .zip and .tar.gz
262+
// tar is built-in on macOS and Linux. Windows uses PowerShell Expand-Archive for .zip files.
263263
async function extractArchive(archivePath: string, destDir: string): Promise<void> {
264264
return new Promise((resolve, reject) => {
265-
const proc = spawn("tar", ["-xf", archivePath, "-C", destDir], { stdio: "pipe" });
265+
const isWindows = platform() === "win32";
266+
267+
const proc = isWindows
268+
? spawn(
269+
"powershell",
270+
[
271+
"-NoProfile",
272+
"-Command",
273+
`$ProgressPreference='SilentlyContinue'; Expand-Archive -Path '${archivePath}' -DestinationPath '${destDir}' -Force`,
274+
],
275+
{ stdio: "pipe" }
276+
)
277+
: spawn("tar", ["-xf", archivePath, "-C", destDir], { stdio: "pipe" });
266278

267279
let stderr = "";
268280
proc.stderr?.on("data", (data) => {

0 commit comments

Comments
 (0)