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 { setupBrew } from "../brew"
|
||||||
import { testBin } from "../../utils/tests/test-helpers"
|
import { testBin } from "../../utils/tests/test-helpers"
|
||||||
|
import { InstallationInfo } from "../../utils/setup/setupBin"
|
||||||
|
|
||||||
jest.setTimeout(200000)
|
jest.setTimeout(200000)
|
||||||
describe("setup-brew", () => {
|
describe("setup-brew", () => {
|
||||||
|
@ -7,7 +8,7 @@ describe("setup-brew", () => {
|
||||||
if (process.platform !== "darwin") {
|
if (process.platform !== "darwin") {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
setupBrew("", "", "")
|
const installInfo = setupBrew("", "", "")
|
||||||
await testBin("brew")
|
await testBin("brew", ["--version"], (installInfo as InstallationInfo | undefined)?.binDir)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
|
@ -1,18 +1,28 @@
|
||||||
import { execFileSync } from "child_process"
|
import { execFileSync } from "child_process"
|
||||||
import which from "which"
|
import which from "which"
|
||||||
|
|
||||||
|
let binDir: string | undefined
|
||||||
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||||
export function setupBrew(_version: string, _setupCppDir: string, _arch: string) {
|
export function setupBrew(_version: string, _setupCppDir: string, _arch: string) {
|
||||||
if (!["darwin", "linux"].includes(process.platform)) {
|
if (!["darwin", "linux"].includes(process.platform)) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if (typeof binDir === "string") {
|
||||||
|
return { binDir }
|
||||||
|
}
|
||||||
|
|
||||||
if (which.sync("brew", { nothrow: true }) !== null) {
|
const maybeBinDir = which.sync("brew", { nothrow: true })
|
||||||
return
|
if (maybeBinDir !== null) {
|
||||||
|
binDir = maybeBinDir
|
||||||
|
return { binDir }
|
||||||
}
|
}
|
||||||
|
|
||||||
// brew is not thread-safe
|
// brew is not thread-safe
|
||||||
execFileSync(`/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",
|
stdio: "inherit",
|
||||||
})
|
})
|
||||||
|
binDir = "/usr/local/bin/"
|
||||||
|
|
||||||
|
return { binDir }
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue