Skip to content

Commit d67d7e0

Browse files
committed
fix: use powershell for val.length of more than 1024
1 parent 946065a commit d67d7e0

File tree

4 files changed

+14
-5
lines changed

4 files changed

+14
-5
lines changed

dist/setup_cpp.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/setup_cpp.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/utils/env/addEnv.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,15 @@ export function addEnv(name: string, val: string | undefined) {
2626
}
2727
}
2828

29-
function addEnvSystem(name: string, val: string | undefined) {
29+
function addEnvSystem(name: string, valGiven: string | undefined) {
30+
const val = valGiven ?? ""
3031
switch (process.platform) {
3132
case "win32": {
32-
execa.sync(`setx "${name}" "${val}"`)
33+
if (val.length <= 1024) {
34+
execa.sync(`setx "${name}" "${val}"`)
35+
} else {
36+
execa.sync(`powershell -C "[Environment]::SetEnvironmentVariable('${name}', '${val}', 'User')"`)
37+
}
3338
core.info(`${name}="${val} was set in the environment."`)
3439
return
3540
}

src/utils/path/addPath.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,11 @@ export function addPath(path: string) {
2828
function addPathSystem(path: string) {
2929
switch (process.platform) {
3030
case "win32": {
31-
execa.sync(`setx PATH "${path};%PATH%"`)
31+
if (`${path};${process.env.PATH}`.length <= 1024) {
32+
execa.sync(`setx PATH "${path};%PATH%"`)
33+
} else {
34+
execa.sync(`powershell -C "[Environment]::SetEnvironmentVariable('PATH', \\"${path};$env:PATH\\", 'User')"`)
35+
}
3236
core.info(`${path} was added to the PATH.`)
3337
return
3438
}

0 commit comments

Comments
 (0)