fix: install brew synchronously

This commit is contained in:
Amin Yahyaabadi 2021-09-16 04:28:33 -05:00
parent eaec708616
commit 841f079886
2 changed files with 8 additions and 11 deletions

View File

@ -1,7 +1,7 @@
import { exec } from "@actions/exec"
import { execFileSync } from "child_process"
import which from "which"
export async function setupBrew() {
export function setupBrew() {
if (!["darwin", "linux"].includes(process.platform)) {
return
}
@ -10,11 +10,8 @@ export async function setupBrew() {
return
}
const exit = await exec(
`/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"`
)
if (exit !== 0) {
throw new Error(`Failed to install brew`)
}
// brew is not thread-safe
execFileSync(`/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"`, {
stdio: "inherit",
})
}

View File

@ -6,9 +6,9 @@ import { setupBrew } from "../../brew/brew"
let hasBrew = false
/** 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) {
await setupBrew()
setupBrew()
hasBrew = true
}