mirror of https://github.com/aminya/setup-cpp
fix: use powershell for val.length of more than 1024
This commit is contained in:
parent
946065a48d
commit
d67d7e0c03
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -26,10 +26,15 @@ export function addEnv(name: string, val: string | undefined) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function addEnvSystem(name: string, val: string | undefined) {
|
function addEnvSystem(name: string, valGiven: string | undefined) {
|
||||||
|
const val = valGiven ?? ""
|
||||||
switch (process.platform) {
|
switch (process.platform) {
|
||||||
case "win32": {
|
case "win32": {
|
||||||
execa.sync(`setx "${name}" "${val}"`)
|
if (val.length <= 1024) {
|
||||||
|
execa.sync(`setx "${name}" "${val}"`)
|
||||||
|
} else {
|
||||||
|
execa.sync(`powershell -C "[Environment]::SetEnvironmentVariable('${name}', '${val}', 'User')"`)
|
||||||
|
}
|
||||||
core.info(`${name}="${val} was set in the environment."`)
|
core.info(`${name}="${val} was set in the environment."`)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,7 +28,11 @@ export function addPath(path: string) {
|
||||||
function addPathSystem(path: string) {
|
function addPathSystem(path: string) {
|
||||||
switch (process.platform) {
|
switch (process.platform) {
|
||||||
case "win32": {
|
case "win32": {
|
||||||
execa.sync(`setx PATH "${path};%PATH%"`)
|
if (`${path};${process.env.PATH}`.length <= 1024) {
|
||||||
|
execa.sync(`setx PATH "${path};%PATH%"`)
|
||||||
|
} else {
|
||||||
|
execa.sync(`powershell -C "[Environment]::SetEnvironmentVariable('PATH', \\"${path};$env:PATH\\", 'User')"`)
|
||||||
|
}
|
||||||
core.info(`${path} was added to the PATH.`)
|
core.info(`${path} was added to the PATH.`)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue