Skip to content

Commit

Permalink
[Windows] Refactor Install-NodeJS script (#11088)
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexey-Ayupov authored Dec 4, 2024
1 parent 0786943 commit e6d1876
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 6 deletions.
15 changes: 12 additions & 3 deletions images/windows/scripts/build/Install-NodeJS.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,18 @@ New-Item -Path $prefixPath -Force -ItemType Directory
New-Item -Path $cachePath -Force -ItemType Directory

$defaultVersion = (Get-ToolsetContent).node.default
$versionToInstall = Resolve-ChocoPackageVersion -PackageName "nodejs" -TargetVersion $defaultVersion

Install-ChocoPackage "nodejs" -ArgumentList "--version=$versionToInstall"
$nodeVersion = (Get-GithubReleasesByVersion -Repo "nodejs/node" -Version "${defaultVersion}").version | Select-Object -First 1
$downloadUrl = "https://nodejs.org/dist/v${nodeVersion}/node-v${nodeVersion}-x64.msi"

$packageName = Split-Path $downloadUrl -Leaf
$externalHash = Get-ChecksumFromUrl -Type "SHA256" `
-Url ($downloadUrl -replace $packageName, "SHASUMS256.txt") `
-FileName $packageName

Install-Binary -Type MSI `
-Url $downloadUrl `
-ExtraInstallArgs @('ADDLOCAL=ALL') `
-ExpectedSHA256Sum $externalHash

Add-MachinePathItem $prefixPath
Update-Environment
Expand Down
2 changes: 1 addition & 1 deletion images/windows/toolsets/toolset-2019.json
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,7 @@
]
},
"node": {
"default": "18"
"default": "18.*"
},
"maven": {
"version": "3.8"
Expand Down
2 changes: 1 addition & 1 deletion images/windows/toolsets/toolset-2022.json
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@
]
},
"node": {
"default": "18"
"default": "18.*"
},
"maven": {
"version": "3.8"
Expand Down
2 changes: 1 addition & 1 deletion images/windows/toolsets/toolset-2025.json
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@
]
},
"node": {
"default": "22"
"default": "22.*"
},
"maven": {
"version": "3.9"
Expand Down

0 comments on commit e6d1876

Please sign in to comment.