mirror of https://github.com/aminya/setup-cpp
fix: fix brew path
This commit is contained in:
parent
5993d7b019
commit
a6648a2296
|
@ -1,5 +1,6 @@
|
|||
import { setupBrew } from "../brew"
|
||||
import { testBin } from "../../utils/tests/test-helpers"
|
||||
import { InstallationInfo } from "../../utils/setup/setupBin"
|
||||
|
||||
jest.setTimeout(200000)
|
||||
describe("setup-brew", () => {
|
||||
|
@ -7,7 +8,7 @@ describe("setup-brew", () => {
|
|||
if (process.platform !== "darwin") {
|
||||
return
|
||||
}
|
||||
setupBrew("", "", "")
|
||||
await testBin("brew")
|
||||
const installInfo = setupBrew("", "", "")
|
||||
await testBin("brew", ["--version"], (installInfo as InstallationInfo | undefined)?.binDir)
|
||||
})
|
||||
})
|
||||
|
|
|
@ -1,18 +1,28 @@
|
|||
import { execFileSync } from "child_process"
|
||||
import which from "which"
|
||||
|
||||
let binDir: string | undefined
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
export function setupBrew(_version: string, _setupCppDir: string, _arch: string) {
|
||||
if (!["darwin", "linux"].includes(process.platform)) {
|
||||
return
|
||||
}
|
||||
if (typeof binDir === "string") {
|
||||
return { binDir }
|
||||
}
|
||||
|
||||
if (which.sync("brew", { nothrow: true }) !== null) {
|
||||
return
|
||||
const maybeBinDir = which.sync("brew", { nothrow: true })
|
||||
if (maybeBinDir !== null) {
|
||||
binDir = maybeBinDir
|
||||
return { binDir }
|
||||
}
|
||||
|
||||
// brew is not thread-safe
|
||||
execFileSync(`/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"`, {
|
||||
stdio: "inherit",
|
||||
})
|
||||
binDir = "/usr/local/bin/"
|
||||
|
||||
return { binDir }
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue