mirror of https://github.com/aminya/setup-cpp
fix: add native fallback for addPath
This commit is contained in:
parent
405234b70c
commit
a778f9bfce
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -1,15 +1,30 @@
|
|||
import { addPath as ghAddPath } from "@actions/core"
|
||||
import { delimiter } from "path"
|
||||
import * as core from "@actions/core"
|
||||
import { exec } from "@actions/exec"
|
||||
|
||||
/** An add path function that works locally or inside GitHub Actions */
|
||||
export function addPath(path: string) {
|
||||
export async function addPath(path: string) {
|
||||
try {
|
||||
ghAddPath(path)
|
||||
} catch (err) {
|
||||
core.error(err as Error)
|
||||
core.error(`Failed to add ${path} to the percistent PATH. You should add it manually.`)
|
||||
process.env.PATH = `${path}${delimiter}${process.env.PATH}`
|
||||
// TODO shell out to add path
|
||||
switch (process.platform) {
|
||||
case "win32": {
|
||||
await exec(`setx PATH=${path};%PATH%`)
|
||||
break
|
||||
}
|
||||
case "linux":
|
||||
case "darwin": {
|
||||
await exec(`echo "export PATH=${path}:$PATH" >> ~/.profile`)
|
||||
await exec(`source ~/.profile`)
|
||||
core.info(`${path} was added to ~/.profile`)
|
||||
break
|
||||
}
|
||||
default: {
|
||||
core.error(`Failed to add ${path} to the percistent PATH. You should add it manually.`)
|
||||
process.env.PATH = `${path}${delimiter}${process.env.PATH}`
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue