mirror of https://github.com/aminya/setup-cpp
fix: use cross-spawn instead of @actions/exec
to support color and inputs
This commit is contained in:
parent
b263e7930c
commit
5cffd3930a
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -1,5 +1,5 @@
|
|||
/* eslint-disable require-atomic-updates */
|
||||
import { exec } from "@actions/exec"
|
||||
import spawn from "cross-spawn"
|
||||
import { existsSync } from "fs"
|
||||
import { dirname } from "path"
|
||||
import which from "which"
|
||||
|
@ -7,14 +7,14 @@ import { InstallationInfo } from "../utils/setup/setupBin"
|
|||
|
||||
let binDir: string | undefined
|
||||
|
||||
export async function setupChocolatey(
|
||||
export function setupChocolatey(
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
_version: string,
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
_setupCppDir: string,
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
_arch: string
|
||||
): Promise<InstallationInfo | undefined> {
|
||||
): InstallationInfo | undefined {
|
||||
if (process.platform !== "win32") {
|
||||
return undefined
|
||||
}
|
||||
|
@ -30,9 +30,10 @@ export async function setupChocolatey(
|
|||
}
|
||||
|
||||
// https://docs.chocolatey.org/en-us/choco/setup#install-with-cmd.exe
|
||||
const exit = await exec(
|
||||
`@"%SystemRoot%\\System32\\WindowsPowerShell\\v1.0\\powershell.exe" -NoProfile -InputFormat None -ExecutionPolicy Bypass -Command "[System.Net.ServicePointManager]::SecurityProtocol = 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))" && SET "PATH=%PATH%;%ALLUSERSPROFILE%\\chocolatey\\bin"`
|
||||
)
|
||||
const exit = spawn.sync(
|
||||
`@"%SystemRoot%\\System32\\WindowsPowerShell\\v1.0\\powershell.exe" -NoProfile -InputFormat None -ExecutionPolicy Bypass -Command "[System.Net.ServicePointManager]::SecurityProtocol = 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))" && SET "PATH=%PATH%;%ALLUSERSPROFILE%\\chocolatey\\bin"`,
|
||||
{ stdio: "inherit" }
|
||||
).status
|
||||
|
||||
if (exit !== 0) {
|
||||
throw new Error(`Failed to install chocolatey`)
|
||||
|
|
|
@ -1,37 +1,33 @@
|
|||
/* eslint-disable require-atomic-updates */
|
||||
import { exec } from "@actions/exec"
|
||||
import spawn from "cross-spawn"
|
||||
import { InstallationInfo } from "./setupBin"
|
||||
import { mightSudo } from "./sudo"
|
||||
|
||||
let didUpdate: boolean = false
|
||||
|
||||
/** A function that installs a package using apt */
|
||||
export async function setupAptPack(
|
||||
name: string,
|
||||
version?: string,
|
||||
repository: boolean | string = true
|
||||
): Promise<InstallationInfo> {
|
||||
export function setupAptPack(name: string, version?: string, repository: boolean | string = true): InstallationInfo {
|
||||
const apt = mightSudo("apt-get")
|
||||
|
||||
let exit = 0
|
||||
let exit: number | null = 0
|
||||
|
||||
if (typeof repository === "string") {
|
||||
exit = await exec(mightSudo("add-apt-repository"), ["--update", repository])
|
||||
exit = spawn.sync(mightSudo("add-apt-repository"), ["--update", repository], { stdio: "inherit" }).status
|
||||
}
|
||||
|
||||
if (!didUpdate || repository === true) {
|
||||
await exec(apt, ["update"])
|
||||
exit = spawn.sync(apt, ["update"], { stdio: "inherit" }).status
|
||||
didUpdate = true
|
||||
}
|
||||
|
||||
if (version !== undefined && version !== "") {
|
||||
try {
|
||||
exit = await exec(apt, ["install", `${name}=${version}`])
|
||||
exit = spawn.sync(apt, ["install", `${name}=${version}`], { stdio: "inherit" }).status
|
||||
} catch {
|
||||
exit = await exec(apt, ["install", `${name}-${version}`])
|
||||
exit = spawn.sync(apt, ["install", `${name}-${version}`], { stdio: "inherit" }).status
|
||||
}
|
||||
} else {
|
||||
exit = await exec(apt, ["install", name])
|
||||
exit = spawn.sync(apt, ["install", name], { stdio: "inherit" }).status
|
||||
}
|
||||
|
||||
if (exit !== 0) {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/* eslint-disable require-atomic-updates */
|
||||
import { execFileSync } from "child_process"
|
||||
import spawn from "cross-spawn"
|
||||
import which from "which"
|
||||
import { setupBrew } from "../../brew/brew"
|
||||
import { InstallationInfo } from "./setupBin"
|
||||
|
@ -14,7 +14,7 @@ export function setupBrewPack(name: string, version?: string): InstallationInfo
|
|||
}
|
||||
|
||||
// brew is not thread-safe
|
||||
execFileSync("brew", ["install", version !== undefined && version !== "" ? `${name}@${version}` : name], {
|
||||
spawn.sync("brew", ["install", version !== undefined && version !== "" ? `${name}@${version}` : name], {
|
||||
stdio: "inherit",
|
||||
})
|
||||
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
/* eslint-disable require-atomic-updates */
|
||||
import { addPath } from "@actions/core"
|
||||
import { exec } from "@actions/exec"
|
||||
import which from "which"
|
||||
import { setupChocolatey } from "../../chocolatey/chocolatey"
|
||||
import { InstallationInfo } from "./setupBin"
|
||||
import spawn from "cross-spawn"
|
||||
|
||||
let hasChoco = false
|
||||
|
||||
|
@ -16,9 +16,9 @@ export async function setupChocoPack(name: string, version?: string, args: strin
|
|||
|
||||
let exit
|
||||
if (version !== undefined && version !== "") {
|
||||
exit = await exec("choco", ["install", "-y", name, `--version=${version}`, ...args])
|
||||
exit = spawn.sync("choco", ["install", "-y", name, `--version=${version}`, ...args], { stdio: "inherit" }).status
|
||||
} else {
|
||||
exit = await exec("choco", ["install", "-y", name, ...args])
|
||||
exit = spawn.sync("choco", ["install", "-y", name, ...args], { stdio: "inherit" }).status
|
||||
}
|
||||
|
||||
if (exit !== 0) {
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
/* eslint-disable require-atomic-updates */
|
||||
import { exec, getExecOutput } from "@actions/exec"
|
||||
import { getExecOutput } from "@actions/exec"
|
||||
import spawn from "cross-spawn"
|
||||
import which from "which"
|
||||
import { addPath, info } from "@actions/core"
|
||||
import { setupPython } from "../../python/python"
|
||||
|
@ -24,7 +25,9 @@ export async function setupPipPack(name: string, version?: string) {
|
|||
}
|
||||
}
|
||||
|
||||
const exit = await exec(pip, ["install", version !== undefined && version !== "" ? `${name}==${version}` : name])
|
||||
const exit = spawn.sync(pip, ["install", version !== undefined && version !== "" ? `${name}==${version}` : name], {
|
||||
stdio: "inherit",
|
||||
}).status
|
||||
if (exit !== 0) {
|
||||
throw new Error(`Failed to install ${name} ${version}`)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue