mirror of https://github.com/aminya/setup-cpp
fix: try-catch adding path using system
This commit is contained in:
parent
d749362c4e
commit
d81b44b112
|
@ -8,23 +8,28 @@ export async function addPath(path: string) {
|
|||
try {
|
||||
ghAddPath(path)
|
||||
} catch (err) {
|
||||
core.error(err as Error)
|
||||
switch (process.platform) {
|
||||
case "win32": {
|
||||
await execa(`setx PATH=${path};%PATH%`)
|
||||
break
|
||||
}
|
||||
case "linux":
|
||||
case "darwin": {
|
||||
await execa.command(`echo "export PATH=${path}:$PATH" >> ~/.profile`)
|
||||
await execa.command(`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}`
|
||||
try {
|
||||
core.error(err as Error)
|
||||
switch (process.platform) {
|
||||
case "win32": {
|
||||
await execa(`setx PATH=${path};%PATH%`)
|
||||
return
|
||||
}
|
||||
case "linux":
|
||||
case "darwin": {
|
||||
await execa.command(`echo "export PATH=${path}:$PATH" >> ~/.profile`)
|
||||
await execa.command(`source ~/.profile`)
|
||||
core.info(`${path} was added to ~/.profile`)
|
||||
return
|
||||
}
|
||||
default: {
|
||||
// fall through shell path modification
|
||||
}
|
||||
}
|
||||
} catch (err2) {
|
||||
core.error(err2 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}`
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue