mirror of https://github.com/aminya/setup-cpp
fix: fix the brew installation on Linux
This commit is contained in:
parent
45d9ac5ca2
commit
3ba3a1b365
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
|
@ -7,7 +7,7 @@ describe("setup-brew", () => {
|
|||
if (process.platform !== "darwin") {
|
||||
return
|
||||
}
|
||||
const installInfo = setupBrew("", "", process.arch)
|
||||
const installInfo = await setupBrew("", "", process.arch)
|
||||
await testBin("brew", ["--version"], installInfo?.binDir)
|
||||
})
|
||||
})
|
||||
|
|
|
@ -1,11 +1,15 @@
|
|||
import { execFileSync } from "child_process"
|
||||
import execa from "execa"
|
||||
import { dirname } from "patha"
|
||||
import which from "which"
|
||||
import { tmpdir } from "os"
|
||||
import path, { join } from "path"
|
||||
import { mkdirP } from "@actions/io"
|
||||
import { readFileSync } from "fs"
|
||||
|
||||
let binDir: string | undefined
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
export function setupBrew(_version: string, _setupDir: string, _arch: string) {
|
||||
export async function setupBrew(_version: string, _setupDir: string, _arch: string) {
|
||||
if (!["darwin", "linux"].includes(process.platform)) {
|
||||
return undefined
|
||||
}
|
||||
|
@ -20,8 +24,25 @@ export function setupBrew(_version: string, _setupDir: string, _arch: string) {
|
|||
}
|
||||
|
||||
// brew is not thread-safe
|
||||
execFileSync(`/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"`, {
|
||||
const brewTempDirectory = path.join(tmpdir(), "setup_cpp", "brew")
|
||||
await mkdirP(brewTempDirectory)
|
||||
|
||||
execa.sync("curl", ["-LJO", "https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh"], {
|
||||
cwd: brewTempDirectory,
|
||||
})
|
||||
const installSh = join(brewTempDirectory, "install.sh")
|
||||
|
||||
if (process.platform === "linux") {
|
||||
const installShContent = readFileSync(installSh, "utf-8")
|
||||
|
||||
installShContent.replace("#!/bin/bash", "")
|
||||
}
|
||||
|
||||
execa.sync("/bin/bash", [installSh], {
|
||||
stdio: "inherit",
|
||||
env: {
|
||||
NONINTERACTIVE: "1",
|
||||
},
|
||||
})
|
||||
binDir = "/usr/local/bin/"
|
||||
|
||||
|
|
Loading…
Reference in New Issue