Skip to content

Commit 3ba3a1b

Browse files
committed
fix: fix the brew installation on Linux
1 parent 45d9ac5 commit 3ba3a1b

File tree

6 files changed

+29
-8
lines changed

6 files changed

+29
-8
lines changed

dist/node12/setup_cpp.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/node12/setup_cpp.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/node16/setup_cpp.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/node16/setup_cpp.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/brew/__tests__/brew.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ describe("setup-brew", () => {
77
if (process.platform !== "darwin") {
88
return
99
}
10-
const installInfo = setupBrew("", "", process.arch)
10+
const installInfo = await setupBrew("", "", process.arch)
1111
await testBin("brew", ["--version"], installInfo?.binDir)
1212
})
1313
})

src/brew/brew.ts

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
1-
import { execFileSync } from "child_process"
1+
import execa from "execa"
22
import { dirname } from "patha"
33
import which from "which"
4+
import { tmpdir } from "os"
5+
import path, { join } from "path"
6+
import { mkdirP } from "@actions/io"
7+
import { readFileSync } from "fs"
48

59
let binDir: string | undefined
610

711
// eslint-disable-next-line @typescript-eslint/no-unused-vars
8-
export function setupBrew(_version: string, _setupDir: string, _arch: string) {
12+
export async function setupBrew(_version: string, _setupDir: string, _arch: string) {
913
if (!["darwin", "linux"].includes(process.platform)) {
1014
return undefined
1115
}
@@ -20,8 +24,25 @@ export function setupBrew(_version: string, _setupDir: string, _arch: string) {
2024
}
2125

2226
// brew is not thread-safe
23-
execFileSync(`/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"`, {
27+
const brewTempDirectory = path.join(tmpdir(), "setup_cpp", "brew")
28+
await mkdirP(brewTempDirectory)
29+
30+
execa.sync("curl", ["-LJO", "https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh"], {
31+
cwd: brewTempDirectory,
32+
})
33+
const installSh = join(brewTempDirectory, "install.sh")
34+
35+
if (process.platform === "linux") {
36+
const installShContent = readFileSync(installSh, "utf-8")
37+
38+
installShContent.replace("#!/bin/bash", "")
39+
}
40+
41+
execa.sync("/bin/bash", [installSh], {
2442
stdio: "inherit",
43+
env: {
44+
NONINTERACTIVE: "1",
45+
},
2546
})
2647
binDir = "/usr/local/bin/"
2748

0 commit comments

Comments
 (0)