Skip to content

Commit f446a06

Browse files
committed
fix: update choco installation
1 parent 8046f31 commit f446a06

File tree

3 files changed

+23
-5
lines changed

3 files changed

+23
-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/chocolatey/chocolatey.ts

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import execa from "execa"
33
import { existsSync } from "fs"
44
import { dirname } from "path"
55
import which from "which"
6+
import { addPath } from "../utils/path/addPath"
67
import { InstallationInfo } from "../utils/setup/setupBin"
78

89
let binDir: string | undefined
@@ -29,10 +30,27 @@ export function setupChocolatey(
2930
return { binDir }
3031
}
3132

33+
let powershell = "powershell.exe"
34+
const maybePowerShell = which.sync(`${process.env.SystemRoot}\\System32\\WindowsPowerShell\\v1.0\\powershell.exe`, {
35+
nothrow: true,
36+
})
37+
if (maybePowerShell !== null) {
38+
powershell = maybePowerShell
39+
}
40+
3241
// https://docs.chocolatey.org/en-us/choco/setup#install-with-cmd.exe
33-
execa.commandSync(
34-
`@"%SystemRoot%\\System32\\WindowsPowerShell\\v1.0\\powershell.exe" -NoProfile -InputFormat None -ExecutionPolicy Bypass -Command "[System.Net.ServicePointManager]::SecurityProtocol = 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))" && SET "PATH=%PATH%;%ALLUSERSPROFILE%\\chocolatey\\bin"`
35-
)
42+
execa.sync(powershell, [
43+
"-NoProfile",
44+
"-InputFormat",
45+
"None",
46+
"-ExecutionPolicy",
47+
"Bypass",
48+
"-Command",
49+
"[System.Net.ServicePointManager]::SecurityProtocol = 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))",
50+
])
51+
52+
const chocoPath = `${process.env.ALLUSERSPROFILE}\\chocolatey\\bin`
53+
addPath(chocoPath)
3654

3755
const maybeChoco = which.sync("choco", { nothrow: true })
3856
if (maybeChoco !== null) {

0 commit comments

Comments
 (0)