mirror of https://github.com/aminya/setup-cpp
Merge pull request #263 from aminya/brew-overwrite [skip ci]
This commit is contained in:
commit
35ec48abe6
1
.npmrc
1
.npmrc
|
@ -1,2 +1,3 @@
|
|||
package-lock=false
|
||||
lockfile=true
|
||||
public-hoist-pattern=['*eslint*', '*prettier*', '*@types*']
|
||||
|
|
|
@ -29,6 +29,7 @@ words:
|
|||
- iarna
|
||||
- cobertura
|
||||
- copr
|
||||
- pnpx
|
||||
- CPATH
|
||||
- Cppcheck
|
||||
- CPPFLAGS
|
||||
|
|
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
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
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
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
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
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
|
@ -105,7 +105,7 @@
|
|||
"numerous": "1.0.3",
|
||||
"envosman": "workspace:*",
|
||||
"p-timeout": "^6.1.2",
|
||||
"parcel": "2.12.0",
|
||||
"parcel": "2.0.0-canary.1717",
|
||||
"path-exists": "^5.0.0",
|
||||
"patha": "^0.4.1",
|
||||
"prettier": "3.2.2",
|
||||
|
|
836
pnpm-lock.yaml
836
pnpm-lock.yaml
File diff suppressed because it is too large
Load Diff
|
@ -48,7 +48,7 @@ export async function setupBrew(_version: string, _setupDir: string, _arch: stri
|
|||
})
|
||||
|
||||
// add the bin directory to the PATH
|
||||
binDir = getBrewPath()
|
||||
binDir = getBrewBinDir()
|
||||
await addPath(binDir, rcOptions)
|
||||
|
||||
return { binDir }
|
||||
|
@ -60,7 +60,7 @@ export async function setupBrew(_version: string, _setupDir: string, _arch: stri
|
|||
*
|
||||
* Based on the installation script from https://brew.sh
|
||||
*/
|
||||
export function getBrewPath() {
|
||||
export function getBrewBinDir() {
|
||||
if (process.platform === "darwin") {
|
||||
if (process.arch === "arm64") {
|
||||
return "/opt/homebrew/bin/"
|
||||
|
|
|
@ -21,7 +21,7 @@ export async function setupPowershell(version: string | undefined, _setupDir: st
|
|||
return { binDir }
|
||||
}
|
||||
case "darwin": {
|
||||
return setupBrewPack("powershell", version, ["--cask"])
|
||||
return setupBrewPack("powershell", version, { cask: true, overwrite: false })
|
||||
}
|
||||
case "linux": {
|
||||
if (isArch()) {
|
||||
|
|
|
@ -3,17 +3,33 @@ import { info } from "@actions/core"
|
|||
import { execaSync } from "execa"
|
||||
import { join } from "patha"
|
||||
import which from "which"
|
||||
import { getBrewPath, setupBrew } from "../../brew/brew.js"
|
||||
import { getBrewBinDir, setupBrew } from "../../brew/brew.js"
|
||||
import type { InstallationInfo } from "./setupBin.js"
|
||||
|
||||
let hasBrew = false
|
||||
|
||||
type BrewPackOptions = {
|
||||
/** Whether to overwrite the package if it already exists */
|
||||
overwrite?: boolean
|
||||
/** Whether to install the package as a cask */
|
||||
cask?: boolean
|
||||
/** Extra args */
|
||||
args?: string[]
|
||||
}
|
||||
|
||||
/** A function that installs a package using brew */
|
||||
export async function setupBrewPack(
|
||||
name: string,
|
||||
version?: string,
|
||||
extraArgs: string[] = [],
|
||||
givenOptions: BrewPackOptions = {},
|
||||
): Promise<InstallationInfo> {
|
||||
const options = {
|
||||
overwrite: true,
|
||||
cask: false,
|
||||
args: [],
|
||||
...givenOptions,
|
||||
}
|
||||
|
||||
info(`Installing ${name} ${version ?? ""} via brew`)
|
||||
|
||||
if (!hasBrew || which.sync("brew", { nothrow: true }) === null) {
|
||||
|
@ -21,16 +37,23 @@ export async function setupBrewPack(
|
|||
hasBrew = true
|
||||
}
|
||||
|
||||
const binDir = getBrewPath()
|
||||
const binDir = getBrewBinDir()
|
||||
const brewPath = join(binDir, "brew")
|
||||
|
||||
// Args
|
||||
const args = [
|
||||
"install",
|
||||
(version !== undefined && version !== "") ? `${name}@${version}` : name,
|
||||
]
|
||||
if (options.overwrite) {
|
||||
args.push("--overwrite")
|
||||
}
|
||||
if (options.cask) {
|
||||
args.push("--cask")
|
||||
}
|
||||
|
||||
// brew is not thread-safe
|
||||
execaSync(
|
||||
join(binDir, "brew"),
|
||||
["install", version !== undefined && version !== "" ? `${name}@${version}` : name, ...extraArgs],
|
||||
{
|
||||
stdio: "inherit",
|
||||
},
|
||||
)
|
||||
execaSync(brewPath, args, { stdio: "inherit" })
|
||||
|
||||
return { binDir }
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue