fix: fix llvm extraction on windows

This commit is contained in:
Amin Yahyaabadi 2021-09-14 10:00:30 -05:00
parent 5be5e74675
commit 096cd4150c
2 changed files with 9 additions and 2 deletions

View File

@ -1,4 +1,5 @@
import * as core from "@actions/core"
import { exec } from "@actions/exec"
import * as tc from "@actions/tool-cache"
import * as path from "path"
import semverLte from "semver/functions/lte"
@ -271,7 +272,13 @@ async function getLLVMPackageInfo(version: string, platform: NodeJS.Platform): P
binRelativeDir: "bin",
extractFunction:
platform === "win32"
? tc.extractZip
? async (file: string, dest: string) => {
const exit = await exec("7z", ["x", file, `-o${dest}`])
if (exit !== 0) {
throw new Error(`Failed to extract ${file} to ${dest} with 7z`)
}
return dest
}
: (file: string, dest: string) => {
return tc.extractTar(file, dest, "--strip-components=1")
},

View File

@ -15,7 +15,7 @@ export type PackageInfo = {
binRelativeDir: string
/** The function to extract the downloaded archive. It can be `undefined`, if the binary itself is downloaded directly. */
extractFunction?: {
(file: string, dest: string): Promise<string>
(file: string, dest: string): Promise<string> | Promise<void>
}
}