From 096cd4150c4f1bf445a3d67c17f35b63eaa66a93 Mon Sep 17 00:00:00 2001 From: Amin Yahyaabadi Date: Tue, 14 Sep 2021 10:00:30 -0500 Subject: [PATCH] fix: fix llvm extraction on windows --- src/llvm/llvm.ts | 9 ++++++++- src/utils/setup/setupBin.ts | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/llvm/llvm.ts b/src/llvm/llvm.ts index f35d5a53..c0107d19 100644 --- a/src/llvm/llvm.ts +++ b/src/llvm/llvm.ts @@ -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") }, diff --git a/src/utils/setup/setupBin.ts b/src/utils/setup/setupBin.ts index 5ccc1053..ffc96b9c 100644 --- a/src/utils/setup/setupBin.ts +++ b/src/utils/setup/setupBin.ts @@ -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 + (file: string, dest: string): Promise | Promise } }