fix: fix getting the brew path on linux

This commit is contained in:
Amin Yahyaabadi 2022-11-20 21:26:31 -08:00
parent ded42d5c2f
commit 66a38eb0fb
9 changed files with 36 additions and 21 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -46,12 +46,16 @@ export async function setupBrew(_version: string, _setupDir: string, _arch: stri
},
})
if (process.platform === "linux") {
binDir = "/home/linuxbrew/.linuxbrew/bin/"
binDir = getBrewPath()
await addPath(binDir)
} else {
binDir = "/usr/local/bin/"
}
return { binDir }
}
export function getBrewPath() {
if (process.platform === "linux") {
return "/home/linuxbrew/.linuxbrew/bin/"
} else {
return "/usr/local/bin/"
}
}

View File

@ -54,7 +54,7 @@ export async function setupDoxygen(version: string, setupDir: string, arch: stri
return installationInfo
}
case "darwin": {
const installationInfo = setupBrewPack("doxygen", undefined)
const installationInfo = await setupBrewPack("doxygen", undefined)
await setupGraphviz(getVersion("graphviz", undefined), "", arch)
return installationInfo
}

View File

@ -83,7 +83,7 @@ export async function setupGcc(version: string, setupDir: string, arch: string)
break
}
case "darwin": {
installationInfo = setupBrewPack("gcc", version)
installationInfo = await setupBrewPack("gcc", version)
break
}
case "linux": {

View File

@ -15,7 +15,7 @@ export async function setupMake(version: string, _setupDir: string, _arch: strin
return setupChocoPack("make", version)
}
case "darwin": {
setupBrewPack("make", version)
await setupBrewPack("make", version)
await addPath("/usr/local/opt/make/libexec/gnubin")
return { binDir: "/usr/local/opt/make/libexec/gnubin" }
}

View File

@ -1,25 +1,36 @@
/* eslint-disable require-atomic-updates */
import { info } from "@actions/core"
import execa from "execa"
import { join } from "patha"
import which from "which"
import { setupBrew } from "../../brew/brew"
import { getBrewPath, setupBrew } from "../../brew/brew"
import { InstallationInfo } from "./setupBin"
let hasBrew = false
/** A function that installs a package using brew */
export function setupBrewPack(name: string, version?: string, extraArgs: string[] = []): InstallationInfo {
export async function setupBrewPack(
name: string,
version?: string,
extraArgs: string[] = []
): Promise<InstallationInfo> {
info(`Installing ${name} ${version ?? ""} via brew`)
if (!hasBrew || which.sync("brew", { nothrow: true }) === null) {
setupBrew("", "", process.arch)
await setupBrew("", "", process.arch)
hasBrew = true
}
// brew is not thread-safe
execa.sync("brew", ["install", version !== undefined && version !== "" ? `${name}@${version}` : name, ...extraArgs], {
stdio: "inherit",
})
const binDir = getBrewPath()
return { binDir: "/usr/local/bin/" }
// brew is not thread-safe
execa.sync(
join(binDir, "brew"),
["install", version !== undefined && version !== "" ? `${name}@${version}` : name, ...extraArgs],
{
stdio: "inherit",
}
)
return { binDir }
}