|
1 | 1 | /* eslint-disable require-atomic-updates */
|
2 |
| -import spawn from "cross-spawn" |
| 2 | +import { exec } from "@actions/exec" |
3 | 3 | import { InstallationInfo } from "./setupBin"
|
4 | 4 | import { mightSudo } from "./sudo"
|
5 | 5 |
|
6 | 6 | let didUpdate: boolean = false
|
7 | 7 |
|
8 | 8 | /** 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> { |
10 | 14 | const apt = mightSudo("apt-get")
|
11 | 15 |
|
12 | 16 | let exit: number | null = 0
|
13 | 17 |
|
14 | 18 | 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]) |
16 | 20 | }
|
17 | 21 |
|
18 | 22 | if (!didUpdate || repository === true) {
|
19 |
| - exit = spawn.sync(apt, ["update", "-y"], { stdio: "inherit" }).status |
| 23 | + exit = await exec(apt, ["update", "-y"]) |
20 | 24 | didUpdate = true
|
21 | 25 | }
|
22 | 26 |
|
23 | 27 | if (version !== undefined && version !== "") {
|
24 | 28 | try {
|
25 |
| - exit = spawn.sync(apt, ["install", "-y", `${name}=${version}`], { stdio: "inherit" }).status |
| 29 | + exit = await exec(apt, ["install", "-y", `${name}=${version}`]) |
26 | 30 | } catch {
|
27 |
| - exit = spawn.sync(apt, ["install", "-y", `${name}-${version}`], { stdio: "inherit" }).status |
| 31 | + exit = await exec(apt, ["install", "-y", `${name}-${version}`]) |
28 | 32 | }
|
29 | 33 | } else {
|
30 |
| - exit = spawn.sync(apt, ["install", "-y", name], { stdio: "inherit" }).status |
| 34 | + exit = await exec(apt, ["install", "-y", name]) |
31 | 35 | }
|
32 | 36 |
|
33 | 37 | if (exit !== 0) {
|
|
0 commit comments