mirror of https://github.com/aminya/setup-cpp
fix: make addPath sync
This commit is contained in:
parent
34bf57d1ab
commit
9b38d106c8
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -9,7 +9,7 @@ export async function setupCppcheck(version: string | undefined, _setupCppDir: s
|
||||||
case "win32": {
|
case "win32": {
|
||||||
await setupChocoPack("cppcheck", version)
|
await setupChocoPack("cppcheck", version)
|
||||||
const binDir = "C:/Program Files/Cppcheck"
|
const binDir = "C:/Program Files/Cppcheck"
|
||||||
await addPath(binDir)
|
addPath(binDir)
|
||||||
return { binDir }
|
return { binDir }
|
||||||
}
|
}
|
||||||
case "darwin": {
|
case "darwin": {
|
||||||
|
|
|
@ -9,9 +9,9 @@ export async function setupDoxygen(version: string | undefined, _setupCppDir: st
|
||||||
case "win32": {
|
case "win32": {
|
||||||
await setupChocoPack("doxygen.install", version)
|
await setupChocoPack("doxygen.install", version)
|
||||||
await setupChocoPack("graphviz", version)
|
await setupChocoPack("graphviz", version)
|
||||||
await addPath("C:/Program Files/Graphviz/bin")
|
addPath("C:/Program Files/Graphviz/bin")
|
||||||
const binDir = "C:/Program Files/doxygen/bin"
|
const binDir = "C:/Program Files/doxygen/bin"
|
||||||
await addPath(binDir)
|
addPath(binDir)
|
||||||
return { binDir }
|
return { binDir }
|
||||||
}
|
}
|
||||||
case "darwin": {
|
case "darwin": {
|
||||||
|
|
|
@ -18,10 +18,10 @@ export async function setupGcc(version: string, _setupCppDir: string, arch: stri
|
||||||
await setupChocoPack("mingw", version)
|
await setupChocoPack("mingw", version)
|
||||||
if (arch === "x64" && existsSync("C:/tools/mingw64/bin")) {
|
if (arch === "x64" && existsSync("C:/tools/mingw64/bin")) {
|
||||||
binDir = "C:/tools/mingw64/bin"
|
binDir = "C:/tools/mingw64/bin"
|
||||||
await addPath(binDir)
|
addPath(binDir)
|
||||||
} else if (arch === "ia32" && existsSync("C:/tools/mingw32/bin")) {
|
} else if (arch === "ia32" && existsSync("C:/tools/mingw32/bin")) {
|
||||||
binDir = "C:/tools/mingw32/bin"
|
binDir = "C:/tools/mingw32/bin"
|
||||||
await addPath(binDir)
|
addPath(binDir)
|
||||||
} else if (existsSync("C:/ProgramData/Chocolatey/bin/g++.exe")) {
|
} else if (existsSync("C:/ProgramData/Chocolatey/bin/g++.exe")) {
|
||||||
binDir = "C:/ProgramData/Chocolatey/bin/"
|
binDir = "C:/ProgramData/Chocolatey/bin/"
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,6 +8,6 @@ export async function setupOpencppcoverage(version: string | undefined, _setupCp
|
||||||
}
|
}
|
||||||
await setupChocoPack("opencppcoverage", version)
|
await setupChocoPack("opencppcoverage", version)
|
||||||
const binDir = "C:/Program Files/OpenCppCoverage"
|
const binDir = "C:/Program Files/OpenCppCoverage"
|
||||||
await addPath(binDir)
|
addPath(binDir)
|
||||||
return { binDir }
|
return { binDir }
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,7 +50,7 @@ export async function setupPythonViaSystem(version: string, setupCppDir: string,
|
||||||
// Adding the bin dir to the path
|
// Adding the bin dir to the path
|
||||||
/** The directory which the tool is installed to */
|
/** The directory which the tool is installed to */
|
||||||
core.info(`Add ${binDir} to PATH`)
|
core.info(`Add ${binDir} to PATH`)
|
||||||
await addPath(binDir)
|
addPath(binDir)
|
||||||
|
|
||||||
return { installDir, binDir }
|
return { installDir, binDir }
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,7 @@ import * as core from "@actions/core"
|
||||||
import execa from "execa"
|
import execa from "execa"
|
||||||
|
|
||||||
/** An add path function that works locally or inside GitHub Actions */
|
/** An add path function that works locally or inside GitHub Actions */
|
||||||
export async function addPath(path: string) {
|
export function addPath(path: string) {
|
||||||
try {
|
try {
|
||||||
ghAddPath(path)
|
ghAddPath(path)
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
@ -12,13 +12,13 @@ export async function addPath(path: string) {
|
||||||
core.error(err as Error)
|
core.error(err as Error)
|
||||||
switch (process.platform) {
|
switch (process.platform) {
|
||||||
case "win32": {
|
case "win32": {
|
||||||
await execa(`setx PATH=${path};%PATH%`)
|
execa.sync(`setx PATH=${path};%PATH%`)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
case "linux":
|
case "linux":
|
||||||
case "darwin": {
|
case "darwin": {
|
||||||
await execa.command(`echo "export PATH=${path}:$PATH" >> ~/.profile`)
|
execa.commandSync(`echo "export PATH=${path}:$PATH" >> ~/.profile`)
|
||||||
await execa.command(`source ~/.profile`)
|
execa.commandSync(`source ~/.profile`)
|
||||||
core.info(`${path} was added to ~/.profile`)
|
core.info(`${path} was added to ~/.profile`)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,7 +55,7 @@ export async function setupBin(
|
||||||
info(`${name} ${version} was found in the cache.`)
|
info(`${name} ${version} was found in the cache.`)
|
||||||
const installDir = join(dir, extractedFolderName)
|
const installDir = join(dir, extractedFolderName)
|
||||||
const binDir = join(installDir, binRelativeDir)
|
const binDir = join(installDir, binRelativeDir)
|
||||||
await addPath(binDir)
|
addPath(binDir)
|
||||||
return { installDir, binDir }
|
return { installDir, binDir }
|
||||||
}
|
}
|
||||||
} catch {
|
} catch {
|
||||||
|
@ -80,7 +80,7 @@ export async function setupBin(
|
||||||
// Adding the bin dir to the path
|
// Adding the bin dir to the path
|
||||||
/** The directory which the tool is installed to */
|
/** The directory which the tool is installed to */
|
||||||
info(`Add ${binDir} to PATH`)
|
info(`Add ${binDir} to PATH`)
|
||||||
await addPath(binDir)
|
addPath(binDir)
|
||||||
|
|
||||||
// check if inside Github Actions. If so, cache the installation
|
// check if inside Github Actions. If so, cache the installation
|
||||||
if (isCI() && typeof process.env.RUNNER_TOOL_CACHE === "string") {
|
if (isCI() && typeof process.env.RUNNER_TOOL_CACHE === "string") {
|
||||||
|
|
|
@ -21,6 +21,6 @@ export async function setupChocoPack(name: string, version?: string, args: strin
|
||||||
}
|
}
|
||||||
|
|
||||||
const binDir = "C:/ProgramData/Chocolatey/bin/"
|
const binDir = "C:/ProgramData/Chocolatey/bin/"
|
||||||
await addPath(binDir)
|
addPath(binDir)
|
||||||
return { binDir }
|
return { binDir }
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,7 +47,7 @@ export async function setupPipPack(name: string, version?: string) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
info(`${binDir} to PATH`)
|
info(`${binDir} to PATH`)
|
||||||
await addPath(binDir)
|
addPath(binDir)
|
||||||
}
|
}
|
||||||
|
|
||||||
return { binDir }
|
return { binDir }
|
||||||
|
|
Loading…
Reference in New Issue