feat: add setup apt

This commit is contained in:
Amin Yahyaabadi 2021-09-15 03:14:39 -05:00
parent de191063e3
commit cd0ee64e3e
1 changed files with 14 additions and 0 deletions

View File

@ -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}`)
}
}