fix: make addPath sync

This commit is contained in:
Amin Yahyaabadi 2021-09-19 03:49:42 -05:00
parent 34bf57d1ab
commit 9b38d106c8
11 changed files with 17 additions and 17 deletions

2
dist/setup_cpp.js vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -9,7 +9,7 @@ export async function setupCppcheck(version: string | undefined, _setupCppDir: s
case "win32": {
await setupChocoPack("cppcheck", version)
const binDir = "C:/Program Files/Cppcheck"
await addPath(binDir)
addPath(binDir)
return { binDir }
}
case "darwin": {

View File

@ -9,9 +9,9 @@ export async function setupDoxygen(version: string | undefined, _setupCppDir: st
case "win32": {
await setupChocoPack("doxygen.install", 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"
await addPath(binDir)
addPath(binDir)
return { binDir }
}
case "darwin": {

View File

@ -18,10 +18,10 @@ export async function setupGcc(version: string, _setupCppDir: string, arch: stri
await setupChocoPack("mingw", version)
if (arch === "x64" && existsSync("C:/tools/mingw64/bin")) {
binDir = "C:/tools/mingw64/bin"
await addPath(binDir)
addPath(binDir)
} else if (arch === "ia32" && existsSync("C:/tools/mingw32/bin")) {
binDir = "C:/tools/mingw32/bin"
await addPath(binDir)
addPath(binDir)
} else if (existsSync("C:/ProgramData/Chocolatey/bin/g++.exe")) {
binDir = "C:/ProgramData/Chocolatey/bin/"
}

View File

@ -8,6 +8,6 @@ export async function setupOpencppcoverage(version: string | undefined, _setupCp
}
await setupChocoPack("opencppcoverage", version)
const binDir = "C:/Program Files/OpenCppCoverage"
await addPath(binDir)
addPath(binDir)
return { binDir }
}

View File

@ -50,7 +50,7 @@ export async function setupPythonViaSystem(version: string, setupCppDir: string,
// Adding the bin dir to the path
/** The directory which the tool is installed to */
core.info(`Add ${binDir} to PATH`)
await addPath(binDir)
addPath(binDir)
return { installDir, binDir }
}

View File

@ -4,7 +4,7 @@ import * as core from "@actions/core"
import execa from "execa"
/** An add path function that works locally or inside GitHub Actions */
export async function addPath(path: string) {
export function addPath(path: string) {
try {
ghAddPath(path)
} catch (err) {
@ -12,13 +12,13 @@ export async function addPath(path: string) {
core.error(err as Error)
switch (process.platform) {
case "win32": {
await execa(`setx PATH=${path};%PATH%`)
execa.sync(`setx PATH=${path};%PATH%`)
return
}
case "linux":
case "darwin": {
await execa.command(`echo "export PATH=${path}:$PATH" >> ~/.profile`)
await execa.command(`source ~/.profile`)
execa.commandSync(`echo "export PATH=${path}:$PATH" >> ~/.profile`)
execa.commandSync(`source ~/.profile`)
core.info(`${path} was added to ~/.profile`)
return
}

View File

@ -55,7 +55,7 @@ export async function setupBin(
info(`${name} ${version} was found in the cache.`)
const installDir = join(dir, extractedFolderName)
const binDir = join(installDir, binRelativeDir)
await addPath(binDir)
addPath(binDir)
return { installDir, binDir }
}
} catch {
@ -80,7 +80,7 @@ export async function setupBin(
// Adding the bin dir to the path
/** The directory which the tool is installed to */
info(`Add ${binDir} to PATH`)
await addPath(binDir)
addPath(binDir)
// check if inside Github Actions. If so, cache the installation
if (isCI() && typeof process.env.RUNNER_TOOL_CACHE === "string") {

View File

@ -21,6 +21,6 @@ export async function setupChocoPack(name: string, version?: string, args: strin
}
const binDir = "C:/ProgramData/Chocolatey/bin/"
await addPath(binDir)
addPath(binDir)
return { binDir }
}

View File

@ -47,7 +47,7 @@ export async function setupPipPack(name: string, version?: string) {
}
}
info(`${binDir} to PATH`)
await addPath(binDir)
addPath(binDir)
}
return { binDir }