Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit a2dc2bc

Browse filesBrowse files
authored
Merge pull request #369 from aminya/brew-warnings
fix: avoid already installed warnings for brew
2 parents 6eadc0b + 8d0a967 commit a2dc2bc
Copy full SHA for a2dc2bc

File tree

5 files changed

+18
-8
lines changed
Filter options

5 files changed

+18
-8
lines changed

‎dist/legacy/setup-cpp.js

Copy file name to clipboardExpand all lines: dist/legacy/setup-cpp.js
+1-1Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎dist/legacy/setup-cpp.js.map

Copy file name to clipboardExpand all lines: dist/legacy/setup-cpp.js.map
+1-1Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎dist/modern/setup-cpp.mjs

Copy file name to clipboardExpand all lines: dist/modern/setup-cpp.mjs
+1-1Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

‎dist/modern/setup-cpp.mjs.map

Copy file name to clipboardExpand all lines: dist/modern/setup-cpp.mjs.map
+1-1Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎packages/setup-brew/src/install-pack.ts

Copy file name to clipboardExpand all lines: packages/setup-brew/src/install-pack.ts
+14-4Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { join } from "path"
22
import { info, warning } from "ci-log"
3-
import { execaSync } from "execa"
3+
import { execaSync } from "execa" // brew is not thread-safe
44
import which from "which"
55
import type { InstallationInfo } from "./InstallationInfo.js"
66
import type { BrewPackOptions } from "./install-pack-options.js"
@@ -53,11 +53,21 @@ export async function installBrewPack(
5353
}
5454
}
5555

56-
// brew is not thread-safe
57-
execaSync(brewPath, args, { stdio: "inherit" })
56+
// dry run to check if the package is already installed
57+
const dryRun = execaSync(brewPath, [...args, "--dry-run"], { stdio: "pipe" })
58+
const isAlreadyInstalled = dryRun.exitCode === 0
59+
&& (new RegExp(`Warning: ${name}.* is already installed and up-to-date.[\\s\\S]*`)).test(dryRun.stderr)
5860

59-
const installDir = await brewPackInstallDir(name, version)
61+
if (isAlreadyInstalled) {
62+
// if the package is already installed and up-to-date, skip the installation
63+
info(`${name} ${version ?? ""} is already installed and up-to-date`)
64+
} else {
65+
// install the package if not already installed
66+
execaSync(brewPath, args, { stdio: "inherit" })
67+
}
6068

69+
// get the installation directory
70+
const installDir = await brewPackInstallDir(name, version)
6171
if (installDir === undefined) {
6272
warning(`Failed to find installation directory for ${name} ${version}`)
6373
return { binDir: getBrewBinDir(), installDir: undefined }

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.