Skip to content

Commit 3461b7c

Browse files
committed
fix: use exec for apt
1 parent b61c16a commit 3461b7c

File tree

3 files changed

+13
-9
lines changed

3 files changed

+13
-9
lines changed

dist/setup_cpp.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/setup_cpp.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/utils/setup/setupAptPack.ts

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,37 @@
11
/* eslint-disable require-atomic-updates */
2-
import spawn from "cross-spawn"
2+
import { exec } from "@actions/exec"
33
import { InstallationInfo } from "./setupBin"
44
import { mightSudo } from "./sudo"
55

66
let didUpdate: boolean = false
77

88
/** A function that installs a package using apt */
9-
export function setupAptPack(name: string, version?: string, repository: boolean | string = true): InstallationInfo {
9+
export async function setupAptPack(
10+
name: string,
11+
version?: string,
12+
repository: boolean | string = true
13+
): Promise<InstallationInfo> {
1014
const apt = mightSudo("apt-get")
1115

1216
let exit: number | null = 0
1317

1418
if (typeof repository === "string") {
15-
exit = spawn.sync(mightSudo("add-apt-repository"), ["--update", "-y", repository], { stdio: "inherit" }).status
19+
exit = await exec(mightSudo("add-apt-repository"), ["--update", "-y", repository])
1620
}
1721

1822
if (!didUpdate || repository === true) {
19-
exit = spawn.sync(apt, ["update", "-y"], { stdio: "inherit" }).status
23+
exit = await exec(apt, ["update", "-y"])
2024
didUpdate = true
2125
}
2226

2327
if (version !== undefined && version !== "") {
2428
try {
25-
exit = spawn.sync(apt, ["install", "-y", `${name}=${version}`], { stdio: "inherit" }).status
29+
exit = await exec(apt, ["install", "-y", `${name}=${version}`])
2630
} catch {
27-
exit = spawn.sync(apt, ["install", "-y", `${name}-${version}`], { stdio: "inherit" }).status
31+
exit = await exec(apt, ["install", "-y", `${name}-${version}`])
2832
}
2933
} else {
30-
exit = spawn.sync(apt, ["install", "-y", name], { stdio: "inherit" }).status
34+
exit = await exec(apt, ["install", "-y", name])
3135
}
3236

3337
if (exit !== 0) {

0 commit comments

Comments
 (0)