diff --git a/src/utils/setup/setupApt.ts b/src/utils/setup/setupApt.ts new file mode 100644 index 00000000..613224dc --- /dev/null +++ b/src/utils/setup/setupApt.ts @@ -0,0 +1,14 @@ +import { exec } from "@actions/exec" + +/** A function that installs a package using apt */ +export async function setupApt(name: string, version?: string, updateRepositories: boolean = true) { + if (updateRepositories) { + await exec("apt-get", ["update"]) + } + + const exit = await exec("apt-get", ["install", version !== undefined ? `${name}=${version}` : name]) + + if (exit !== 0) { + throw new Error(`Failed to install ${name} ${version}`) + } +}