Skip to content

Commit 66a38eb

Browse files
committed
fix: fix getting the brew path on linux
1 parent ded42d5 commit 66a38eb

File tree

9 files changed

+34
-19
lines changed

9 files changed

+34
-19
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/brew.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,16 @@ export async function setupBrew(_version: string, _setupDir: string, _arch: stri
4646
},
4747
})
4848

49+
binDir = getBrewPath()
50+
await addPath(binDir)
51+
52+
return { binDir }
53+
}
54+
55+
export function getBrewPath() {
4956
if (process.platform === "linux") {
50-
binDir = "/home/linuxbrew/.linuxbrew/bin/"
51-
await addPath(binDir)
57+
return "/home/linuxbrew/.linuxbrew/bin/"
5258
} else {
53-
binDir = "/usr/local/bin/"
59+
return "/usr/local/bin/"
5460
}
55-
56-
return { binDir }
5761
}

src/doxygen/doxygen.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ export async function setupDoxygen(version: string, setupDir: string, arch: stri
5454
return installationInfo
5555
}
5656
case "darwin": {
57-
const installationInfo = setupBrewPack("doxygen", undefined)
57+
const installationInfo = await setupBrewPack("doxygen", undefined)
5858
await setupGraphviz(getVersion("graphviz", undefined), "", arch)
5959
return installationInfo
6060
}

src/gcc/gcc.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ export async function setupGcc(version: string, setupDir: string, arch: string)
8383
break
8484
}
8585
case "darwin": {
86-
installationInfo = setupBrewPack("gcc", version)
86+
installationInfo = await setupBrewPack("gcc", version)
8787
break
8888
}
8989
case "linux": {

src/make/make.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export async function setupMake(version: string, _setupDir: string, _arch: strin
1515
return setupChocoPack("make", version)
1616
}
1717
case "darwin": {
18-
setupBrewPack("make", version)
18+
await setupBrewPack("make", version)
1919
await addPath("/usr/local/opt/make/libexec/gnubin")
2020
return { binDir: "/usr/local/opt/make/libexec/gnubin" }
2121
}

src/utils/setup/setupBrewPack.ts

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,36 @@
11
/* eslint-disable require-atomic-updates */
22
import { info } from "@actions/core"
33
import execa from "execa"
4+
import { join } from "patha"
45
import which from "which"
5-
import { setupBrew } from "../../brew/brew"
6+
import { getBrewPath, setupBrew } from "../../brew/brew"
67
import { InstallationInfo } from "./setupBin"
78

89
let hasBrew = false
910

1011
/** A function that installs a package using brew */
11-
export function setupBrewPack(name: string, version?: string, extraArgs: string[] = []): InstallationInfo {
12+
export async function setupBrewPack(
13+
name: string,
14+
version?: string,
15+
extraArgs: string[] = []
16+
): Promise<InstallationInfo> {
1217
info(`Installing ${name} ${version ?? ""} via brew`)
1318

1419
if (!hasBrew || which.sync("brew", { nothrow: true }) === null) {
15-
setupBrew("", "", process.arch)
20+
await setupBrew("", "", process.arch)
1621
hasBrew = true
1722
}
1823

24+
const binDir = getBrewPath()
25+
1926
// brew is not thread-safe
20-
execa.sync("brew", ["install", version !== undefined && version !== "" ? `${name}@${version}` : name, ...extraArgs], {
21-
stdio: "inherit",
22-
})
27+
execa.sync(
28+
join(binDir, "brew"),
29+
["install", version !== undefined && version !== "" ? `${name}@${version}` : name, ...extraArgs],
30+
{
31+
stdio: "inherit",
32+
}
33+
)
2334

24-
return { binDir: "/usr/local/bin/" }
35+
return { binDir }
2536
}

0 commit comments

Comments
 (0)