mirror of https://github.com/aminya/setup-cpp
fix: use execa instead of cross-spawn and @action/exec
This commit is contained in:
parent
a70ed6421c
commit
9bef371233
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -43,6 +43,7 @@
|
|||
"@actions/exec": "^1.1.0",
|
||||
"@actions/io": "^1.1.1",
|
||||
"@actions/tool-cache": "^1.7.1",
|
||||
"execa": "^5.1.1",
|
||||
"hasha": "^5.2.2",
|
||||
"mri": "^1.2.0",
|
||||
"semver": "^7.3.5",
|
||||
|
|
|
@ -21,6 +21,7 @@ importers:
|
|||
cross-env: 7.0.3
|
||||
cross-spawn: ^7.0.3
|
||||
eslint-config-atomic: ^1.16.2
|
||||
execa: ^5.1.1
|
||||
hasha: ^5.2.2
|
||||
jest: ^27.2.0
|
||||
mri: ^1.2.0
|
||||
|
@ -39,6 +40,7 @@ importers:
|
|||
'@actions/exec': 1.1.0
|
||||
'@actions/io': 1.1.1
|
||||
'@actions/tool-cache': 1.7.1
|
||||
execa: 5.1.1
|
||||
hasha: 5.2.2
|
||||
mri: 1.2.0
|
||||
semver: 7.3.5
|
||||
|
@ -2829,7 +2831,6 @@ packages:
|
|||
path-key: 3.1.1
|
||||
shebang-command: 2.0.0
|
||||
which: 2.0.2
|
||||
dev: true
|
||||
|
||||
/crypto-browserify/3.12.0:
|
||||
resolution: {integrity: sha512-fz4spIh+znjO2VjL+IdhEpRJ3YN6sMzITSBijk6FK2UvTqruSQW+/cCZTSNsMiZNvUeq0CqurF+dAbyiGOY6Wg==}
|
||||
|
@ -3890,7 +3891,6 @@ packages:
|
|||
onetime: 5.1.2
|
||||
signal-exit: 3.0.3
|
||||
strip-final-newline: 2.0.0
|
||||
dev: true
|
||||
|
||||
/exit-on-epipe/1.0.1:
|
||||
resolution: {integrity: sha512-h2z5mrROTxce56S+pnvAV890uu7ls7f1kEvVGJbw1OlFH3/mlJ5bkXu0KRyW94v37zzHPiUd55iLn3DA7TjWpw==}
|
||||
|
@ -4231,7 +4231,6 @@ packages:
|
|||
/get-stream/6.0.1:
|
||||
resolution: {integrity: sha512-ts6Wi+2j3jQjqi70w5AlN8DFnkSwC+MqmxEzdEALB2qXZYV3X/b1CTfgPLGJNMeAWxdPfU8FO1ms3NUfaHCPYg==}
|
||||
engines: {node: '>=10'}
|
||||
dev: true
|
||||
|
||||
/get-symbol-description/1.0.0:
|
||||
resolution: {integrity: sha512-2EmdH1YvIQiZpltCNgkuiUnyukzxM/R6NDJX31Ke3BG1Nq5b0S2PhX59UKi9vZpPDQVdqn+1IcaAwnzTT5vCjw==}
|
||||
|
@ -4565,7 +4564,6 @@ packages:
|
|||
/human-signals/2.1.0:
|
||||
resolution: {integrity: sha512-B4FFZ6q/T2jhhksgkbEW3HBvWIfDW85snkQgawt07S7J5QXTk6BkNV+0yAeZrM5QpMAdYlocGoljn0sJ/WQkFw==}
|
||||
engines: {node: '>=10.17.0'}
|
||||
dev: true
|
||||
|
||||
/iconv-lite/0.4.24:
|
||||
resolution: {integrity: sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==}
|
||||
|
@ -5988,7 +5986,6 @@ packages:
|
|||
|
||||
/merge-stream/2.0.0:
|
||||
resolution: {integrity: sha512-abv/qOcuPfk3URPfDzmZU1LKmuw8kT+0nIHvKrKgFrwifol/doWcdA4ZqsWQ8ENrFKkd67Mfpo/LovbIUsbt3w==}
|
||||
dev: true
|
||||
|
||||
/merge2/1.4.1:
|
||||
resolution: {integrity: sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg==}
|
||||
|
@ -6066,7 +6063,6 @@ packages:
|
|||
/mimic-fn/2.1.0:
|
||||
resolution: {integrity: sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg==}
|
||||
engines: {node: '>=6'}
|
||||
dev: true
|
||||
|
||||
/minimalistic-assert/1.0.1:
|
||||
resolution: {integrity: sha512-UtJcAD4yEaGtjPezWuO9wC4nwUnVH/8/Im3yEHQP4b67cXlD/Qr9hdITCU1xDbSEXg2XKNaP8jsReV7vQd00/A==}
|
||||
|
@ -6246,7 +6242,6 @@ packages:
|
|||
engines: {node: '>=8'}
|
||||
dependencies:
|
||||
path-key: 3.1.1
|
||||
dev: true
|
||||
|
||||
/nth-check/2.0.0:
|
||||
resolution: {integrity: sha512-i4sc/Kj8htBrAiH1viZ0TgU8Y5XqCaV/FziYK6TBczxmeKm3AEFWqqF3195yKudrarqy7Zu80Ra5dobFjn9X/Q==}
|
||||
|
@ -6367,7 +6362,6 @@ packages:
|
|||
engines: {node: '>=6'}
|
||||
dependencies:
|
||||
mimic-fn: 2.1.0
|
||||
dev: true
|
||||
|
||||
/open/7.4.2:
|
||||
resolution: {integrity: sha512-MVHddDVweXZF3awtlAS+6pgKLlm/JgxZ90+/NBurBoQctVOOB/zDdVjcyPzQ+0laDGbsWgrRkflI65sQeOgT9Q==}
|
||||
|
@ -6592,7 +6586,6 @@ packages:
|
|||
/path-key/3.1.1:
|
||||
resolution: {integrity: sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==}
|
||||
engines: {node: '>=8'}
|
||||
dev: true
|
||||
|
||||
/path-parse/1.0.7:
|
||||
resolution: {integrity: sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==}
|
||||
|
@ -7663,7 +7656,6 @@ packages:
|
|||
engines: {node: '>=8'}
|
||||
dependencies:
|
||||
shebang-regex: 3.0.0
|
||||
dev: true
|
||||
|
||||
/shebang-regex/1.0.0:
|
||||
resolution: {integrity: sha1-2kL0l0DAtC2yypcoVxyxkMmO/qM=}
|
||||
|
@ -7673,7 +7665,6 @@ packages:
|
|||
/shebang-regex/3.0.0:
|
||||
resolution: {integrity: sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==}
|
||||
engines: {node: '>=8'}
|
||||
dev: true
|
||||
|
||||
/shell-quote/1.7.2:
|
||||
resolution: {integrity: sha512-mRz/m/JVscCrkMyPqHc/bczi3OQHkLTqXHEFu0zDhK/qfv3UcOA4SVmRCLmos4bhjr9ekVQubj/R7waKapmiQg==}
|
||||
|
@ -7714,7 +7705,6 @@ packages:
|
|||
|
||||
/signal-exit/3.0.3:
|
||||
resolution: {integrity: sha512-VUJ49FC8U1OxwZLxIbTTrDvLnf/6TDgxZcK8wxR8zs13xpx7xbG60ndBlhNrFi2EMuFRoeDoJO7wthSLq42EjA==}
|
||||
dev: true
|
||||
|
||||
/sisteransi/1.0.5:
|
||||
resolution: {integrity: sha512-bLGGlR1QxBcynn2d5YmDX4MGjlZvy2MRBDRNHLJ8VI6l6+9FUiyTFNJ0IveOSP0bcXgVDPRcfGqA0pjaqUpfVg==}
|
||||
|
@ -7994,7 +7984,6 @@ packages:
|
|||
/strip-final-newline/2.0.0:
|
||||
resolution: {integrity: sha512-BrpvfNAE3dcvq7ll3xVumzjKjZQ5tI1sEUIKr3Uoks0XUl45St3FlatVqef9prk4jRDzhW6WZg+3bk93y6pLjA==}
|
||||
engines: {node: '>=6'}
|
||||
dev: true
|
||||
|
||||
/strip-json-comments/1.0.4:
|
||||
resolution: {integrity: sha1-HhX7ysl9Pumb8tc7TGVrCCu6+5E=}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/* eslint-disable require-atomic-updates */
|
||||
import spawn from "cross-spawn"
|
||||
import execa from "execa"
|
||||
import { existsSync } from "fs"
|
||||
import { dirname } from "path"
|
||||
import which from "which"
|
||||
|
@ -30,14 +30,9 @@ export function setupChocolatey(
|
|||
}
|
||||
|
||||
// https://docs.chocolatey.org/en-us/choco/setup#install-with-cmd.exe
|
||||
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`)
|
||||
}
|
||||
execa.commandSync(
|
||||
`@"%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 maybeChoco = which.sync("choco", { nothrow: true })
|
||||
if (maybeChoco !== null) {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { addPath as ghAddPath } from "@actions/core"
|
||||
import { delimiter } from "path"
|
||||
import * as core from "@actions/core"
|
||||
import { exec } from "@actions/exec"
|
||||
import execa from "execa"
|
||||
|
||||
/** An add path function that works locally or inside GitHub Actions */
|
||||
export async function addPath(path: string) {
|
||||
|
@ -11,13 +11,13 @@ export async function addPath(path: string) {
|
|||
core.error(err as Error)
|
||||
switch (process.platform) {
|
||||
case "win32": {
|
||||
await exec(`setx PATH=${path};%PATH%`)
|
||||
await execa(`setx PATH=${path};%PATH%`)
|
||||
break
|
||||
}
|
||||
case "linux":
|
||||
case "darwin": {
|
||||
await exec(`echo "export PATH=${path}:$PATH" >> ~/.profile`)
|
||||
await exec(`source ~/.profile`)
|
||||
await execa.command(`echo "export PATH=${path}:$PATH" >> ~/.profile`)
|
||||
await execa.command(`source ~/.profile`)
|
||||
core.info(`${path} was added to ~/.profile`)
|
||||
break
|
||||
}
|
||||
|
|
|
@ -1,12 +1,9 @@
|
|||
import { exec } from "@actions/exec"
|
||||
import execa from "execa"
|
||||
import { mkdirP } from "@actions/io"
|
||||
export { extractTar, extractXar, extract7z, extractZip } from "@actions/tool-cache"
|
||||
|
||||
export async function extractExe(file: string, dest: string) {
|
||||
const exit = await exec("7z", ["x", file, `-o${dest}`])
|
||||
if (exit !== 0) {
|
||||
throw new Error(`Failed to extract ${file} to ${dest} with 7z`)
|
||||
}
|
||||
await execa("7z", ["x", file, `-o${dest}`])
|
||||
return dest
|
||||
}
|
||||
|
||||
|
@ -16,9 +13,6 @@ export async function extractTarByExe(file: string, dest: string, flags = ["--st
|
|||
} catch {
|
||||
// ignore
|
||||
}
|
||||
const exit = await exec("tar", ["xf", file, "-C", dest, ...flags])
|
||||
if (exit !== 0) {
|
||||
throw new Error(`Failed to extract ${file} to ${dest} with tar`)
|
||||
}
|
||||
await execa("tar", ["xf", file, "-C", dest, ...flags])
|
||||
return dest
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/* eslint-disable require-atomic-updates */
|
||||
import { exec } from "@actions/exec"
|
||||
import execa from "execa"
|
||||
import { InstallationInfo } from "./setupBin"
|
||||
import { mightSudo } from "./sudo"
|
||||
// import { mightSudo } from "./sudo"
|
||||
|
||||
let didUpdate: boolean = false
|
||||
|
||||
|
@ -11,31 +11,25 @@ export async function setupAptPack(
|
|||
version?: string,
|
||||
repository: boolean | string = true
|
||||
): Promise<InstallationInfo> {
|
||||
const apt = mightSudo("apt-get")
|
||||
|
||||
let exit: number | null = 0
|
||||
const apt = "apt-get" // mightSudo
|
||||
|
||||
if (typeof repository === "string") {
|
||||
exit = await exec(mightSudo("add-apt-repository"), ["--update", "-y", repository])
|
||||
await execa("add-apt-repository", ["--update", "-y", repository])
|
||||
}
|
||||
|
||||
if (!didUpdate || repository === true) {
|
||||
exit = await exec(apt, ["update", "-y"])
|
||||
await execa(apt, ["update", "-y"])
|
||||
didUpdate = true
|
||||
}
|
||||
|
||||
if (version !== undefined && version !== "") {
|
||||
try {
|
||||
exit = await exec(apt, ["install", "-y", `${name}=${version}`])
|
||||
await execa(apt, ["install", "-y", `${name}=${version}`])
|
||||
} catch {
|
||||
exit = await exec(apt, ["install", "-y", `${name}-${version}`])
|
||||
await execa(apt, ["install", "-y", `${name}-${version}`])
|
||||
}
|
||||
} else {
|
||||
exit = await exec(apt, ["install", "-y", name])
|
||||
}
|
||||
|
||||
if (exit !== 0) {
|
||||
throw new Error(`Failed to install ${name} ${version}`)
|
||||
await execa(apt, ["install", "-y", name])
|
||||
}
|
||||
|
||||
return { binDir: "/usr/bin/" }
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/* eslint-disable require-atomic-updates */
|
||||
import spawn from "cross-spawn"
|
||||
import execa from "execa"
|
||||
import which from "which"
|
||||
import { setupBrew } from "../../brew/brew"
|
||||
import { InstallationInfo } from "./setupBin"
|
||||
|
@ -14,9 +14,7 @@ export function setupBrewPack(name: string, version?: string): InstallationInfo
|
|||
}
|
||||
|
||||
// brew is not thread-safe
|
||||
spawn.sync("brew", ["install", version !== undefined && version !== "" ? `${name}@${version}` : name], {
|
||||
stdio: "inherit",
|
||||
})
|
||||
execa.sync("brew", ["install", version !== undefined && version !== "" ? `${name}@${version}` : name])
|
||||
|
||||
return { binDir: "/usr/local/bin/" }
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@ import { addPath } from "../path/addPath"
|
|||
import which from "which"
|
||||
import { setupChocolatey } from "../../chocolatey/chocolatey"
|
||||
import { InstallationInfo } from "./setupBin"
|
||||
import spawn from "cross-spawn"
|
||||
import execa from "execa"
|
||||
|
||||
let hasChoco = false
|
||||
|
||||
|
@ -14,15 +14,10 @@ export async function setupChocoPack(name: string, version?: string, args: strin
|
|||
hasChoco = true
|
||||
}
|
||||
|
||||
let exit
|
||||
if (version !== undefined && version !== "") {
|
||||
exit = spawn.sync("choco", ["install", "-y", name, `--version=${version}`, ...args], { stdio: "inherit" }).status
|
||||
execa.sync("choco", ["install", "-y", name, `--version=${version}`, ...args])
|
||||
} else {
|
||||
exit = spawn.sync("choco", ["install", "-y", name, ...args], { stdio: "inherit" }).status
|
||||
}
|
||||
|
||||
if (exit !== 0) {
|
||||
throw new Error(`Failed to install ${name} ${version}`)
|
||||
execa.sync("choco", ["install", "-y", name, ...args])
|
||||
}
|
||||
|
||||
const binDir = "C:/ProgramData/Chocolatey/bin/"
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* eslint-disable require-atomic-updates */
|
||||
import { getExecOutput } from "@actions/exec"
|
||||
import spawn from "cross-spawn"
|
||||
import execa from "execa"
|
||||
import which from "which"
|
||||
import { info } from "@actions/core"
|
||||
import { addPath } from "../path/addPath"
|
||||
|
@ -26,12 +26,7 @@ export async function setupPipPack(name: string, version?: string) {
|
|||
}
|
||||
}
|
||||
|
||||
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}`)
|
||||
}
|
||||
execa.sync(pip, ["install", version !== undefined && version !== "" ? `${name}==${version}` : name])
|
||||
|
||||
if (binDir === undefined) {
|
||||
if (process.platform === "linux") {
|
||||
|
|
Loading…
Reference in New Issue