mirror of https://github.com/aminya/setup-cpp
fix: fix getting the brew path on linux
This commit is contained in:
parent
ded42d5c2f
commit
66a38eb0fb
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
|
@ -46,12 +46,16 @@ export async function setupBrew(_version: string, _setupDir: string, _arch: stri
|
|||
},
|
||||
})
|
||||
|
||||
if (process.platform === "linux") {
|
||||
binDir = "/home/linuxbrew/.linuxbrew/bin/"
|
||||
await addPath(binDir)
|
||||
} else {
|
||||
binDir = "/usr/local/bin/"
|
||||
}
|
||||
binDir = getBrewPath()
|
||||
await addPath(binDir)
|
||||
|
||||
return { binDir }
|
||||
}
|
||||
|
||||
export function getBrewPath() {
|
||||
if (process.platform === "linux") {
|
||||
return "/home/linuxbrew/.linuxbrew/bin/"
|
||||
} else {
|
||||
return "/usr/local/bin/"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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": {
|
||||
|
|
|
@ -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" }
|
||||
}
|
||||
|
|
|
@ -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 }
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue