Skip to content

Commit ba5279b

Browse files
committed
refactor: add getSevenZip function
1 parent f815a5c commit ba5279b

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

src/utils/setup/extract.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,25 @@ import { mkdirP } from "@actions/io"
33
import which from "which"
44
import { setupSevenZip } from "../../sevenzip/sevenzip"
55
import { warning } from "../io/io"
6-
export { extractTar, extractXar, extract7z, extractZip } from "@actions/tool-cache"
6+
export { extractTar, extractXar, extract7z } from "@actions/tool-cache"
77

88
let sevenZip: string | undefined
99

1010
export async function extractExe(file: string, dest: string) {
11-
// install 7z if needed
11+
await execa(await getSevenZip(), ["x", file, `-o${dest}`], { stdio: "inherit" })
12+
return dest
13+
}
14+
15+
/// install 7z if needed
16+
async function getSevenZip() {
1217
if (sevenZip === undefined) {
1318
if (which.sync("7z", { nothrow: true }) === null) {
1419
await setupSevenZip("", "", process.arch)
1520
}
1621
// eslint-disable-next-line require-atomic-updates
1722
sevenZip = "7z"
1823
}
19-
20-
await execa(sevenZip, ["x", file, `-o${dest}`], { stdio: "inherit" })
21-
return dest
24+
return sevenZip
2225
}
2326

2427
export async function extractTarByExe(file: string, dest: string, flags = ["--strip-components=0"]) {

0 commit comments

Comments
 (0)