Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Windows] Rework NodeJS install to use latest version which corresponds to the default #4406

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion images/win/scripts/Installers/Install-NodeLts.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,18 @@ New-Item -Path $PrefixPath -Force -ItemType Directory
New-Item -Path $CachePath -Force -ItemType Directory

$defaultVersion = (Get-ToolsetContent).node.default
Choco-Install -PackageName nodejs -ArgumentList "--version=$defaultVersion"
$queryFilter = "`$filter=(Id eq 'nodejs') and (IsPrerelease eq false) and (Version ge '$defaultVersion')"
$url = "https://community.chocolatey.org/api/v2/Packages()?$queryFilter"
$chocoVersionsOutput = (Invoke-RestMethod -Uri $url).properties.Version
# Take the latest version available for given default version from the toolset which is used as wildcard
# Toolset file can contain a version in any form: Major, Major.Minor or even the exact version
$versionToInstall = $chocoVersionsOutput |
# Take the exact default version and its subversions
Where-Object { $_ -Like "$defaultVersion.*" -or $_ -eq $defaultVersion } |
Sort-Object { [Version]$_ } |
Select-Object -Last 1

Choco-Install -PackageName nodejs -ArgumentList "--version=$versionToInstall"

Add-MachinePathItem $PrefixPath
$env:Path = Get-MachinePath
Expand Down
2 changes: 1 addition & 1 deletion images/win/toolsets/toolset-2016.json
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,6 @@
]
},
"node": {
"default": "14.18.1"
"default": "14"
}
}
2 changes: 1 addition & 1 deletion images/win/toolsets/toolset-2019.json
Original file line number Diff line number Diff line change
Expand Up @@ -453,6 +453,6 @@
]
},
"node": {
"default": "14.18.1"
"default": "14"
}
}
2 changes: 1 addition & 1 deletion images/win/toolsets/toolset-2022.json
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,6 @@
]
},
"node": {
"default": "14.18.1"
"default": "14"
}
}