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 {
|
try {
|
||||||
ghAddPath(path)
|
ghAddPath(path)
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
try {
|
||||||
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%`)
|
await execa(`setx PATH=${path};%PATH%`)
|
||||||
break
|
return
|
||||||
}
|
}
|
||||||
case "linux":
|
case "linux":
|
||||||
case "darwin": {
|
case "darwin": {
|
||||||
await execa.command(`echo "export PATH=${path}:$PATH" >> ~/.profile`)
|
await execa.command(`echo "export PATH=${path}:$PATH" >> ~/.profile`)
|
||||||
await execa.command(`source ~/.profile`)
|
await execa.command(`source ~/.profile`)
|
||||||
core.info(`${path} was added to ~/.profile`)
|
core.info(`${path} was added to ~/.profile`)
|
||||||
break
|
return
|
||||||
}
|
}
|
||||||
default: {
|
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.`)
|
core.error(`Failed to add ${path} to the percistent PATH. You should add it manually.`)
|
||||||
process.env.PATH = `${path}${delimiter}${process.env.PATH}`
|
process.env.PATH = `${path}${delimiter}${process.env.PATH}`
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in New Issue