mirror of https://github.com/aminya/setup-cpp
fix: install brew synchronously
This commit is contained in:
parent
eaec708616
commit
841f079886
|
@ -1,7 +1,7 @@
|
||||||
import { exec } from "@actions/exec"
|
import { execFileSync } from "child_process"
|
||||||
import which from "which"
|
import which from "which"
|
||||||
|
|
||||||
export async function setupBrew() {
|
export function setupBrew() {
|
||||||
if (!["darwin", "linux"].includes(process.platform)) {
|
if (!["darwin", "linux"].includes(process.platform)) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -10,11 +10,8 @@ export async function setupBrew() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
const exit = await exec(
|
// brew is not thread-safe
|
||||||
`/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"`
|
execFileSync(`/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"`, {
|
||||||
)
|
stdio: "inherit",
|
||||||
|
})
|
||||||
if (exit !== 0) {
|
|
||||||
throw new Error(`Failed to install brew`)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,9 +6,9 @@ import { setupBrew } from "../../brew/brew"
|
||||||
let hasBrew = false
|
let hasBrew = false
|
||||||
|
|
||||||
/** A function that installs a package using brew */
|
/** A function that installs a package using brew */
|
||||||
export async function setupBrewPack(name: string, version?: string) {
|
export function setupBrewPack(name: string, version?: string) {
|
||||||
if (!hasBrew || which.sync("brew", { nothrow: true }) === null) {
|
if (!hasBrew || which.sync("brew", { nothrow: true }) === null) {
|
||||||
await setupBrew()
|
setupBrew()
|
||||||
hasBrew = true
|
hasBrew = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue