Skip to content

Commit fa41b67

Browse files
[Win] Rework NodeJS install (#4406)
1 parent 8fd74eb commit fa41b67

File tree

4 files changed

+15
-4
lines changed

4 files changed

+15
-4
lines changed

images/win/scripts/Installers/Install-NodeLts.ps1

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,18 @@ New-Item -Path $PrefixPath -Force -ItemType Directory
1111
New-Item -Path $CachePath -Force -ItemType Directory
1212

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

1627
Add-MachinePathItem $PrefixPath
1728
$env:Path = Get-MachinePath

images/win/toolsets/toolset-2016.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -421,6 +421,6 @@
421421
]
422422
},
423423
"node": {
424-
"default": "14.18.1"
424+
"default": "14"
425425
}
426426
}

images/win/toolsets/toolset-2019.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -453,6 +453,6 @@
453453
]
454454
},
455455
"node": {
456-
"default": "14.18.1"
456+
"default": "14"
457457
}
458458
}

images/win/toolsets/toolset-2022.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,6 @@
303303
]
304304
},
305305
"node": {
306-
"default": "14.18.1"
306+
"default": "14"
307307
}
308308
}

0 commit comments

Comments
 (0)