From 234919982e06424fcb68ac73f07e4cb2fe17ee60 Mon Sep 17 00:00:00 2001 From: Nikolay Frolov <90333448+nikolai-frolov@users.noreply.github.com> Date: Sat, 30 Oct 2021 14:03:05 +0300 Subject: [PATCH] [Windows] Rework NodeJS install (#4375) --- images/win/scripts/Installers/Install-NodeLts.ps1 | 3 ++- images/win/scripts/Tests/Node.Tests.ps1 | 6 ++++++ images/win/toolsets/toolset-2016.json | 3 +++ images/win/toolsets/toolset-2019.json | 3 +++ images/win/toolsets/toolset-2022.json | 3 +++ 5 files changed, 17 insertions(+), 1 deletion(-) diff --git a/images/win/scripts/Installers/Install-NodeLts.ps1 b/images/win/scripts/Installers/Install-NodeLts.ps1 index 3b91ad20..008fafc3 100644 --- a/images/win/scripts/Installers/Install-NodeLts.ps1 +++ b/images/win/scripts/Installers/Install-NodeLts.ps1 @@ -10,7 +10,8 @@ $CachePath = 'C:\npm\cache' New-Item -Path $PrefixPath -Force -ItemType Directory New-Item -Path $CachePath -Force -ItemType Directory -Choco-Install -PackageName nodejs-lts -ArgumentList "--force" +$defaultVersion = (Get-ToolsetContent).node.default +Choco-Install -PackageName nodejs -ArgumentList "--version=$defaultVersion" Add-MachinePathItem $PrefixPath $env:Path = Get-MachinePath diff --git a/images/win/scripts/Tests/Node.Tests.ps1 b/images/win/scripts/Tests/Node.Tests.ps1 index 58577276..720e65b0 100644 --- a/images/win/scripts/Tests/Node.Tests.ps1 +++ b/images/win/scripts/Tests/Node.Tests.ps1 @@ -16,4 +16,10 @@ Describe "Node.JS" { $Test | Should -ReturnZeroExitCode } } + + Context "Node.js version" { + It "Node.js version should correspond to the version in the toolset" { + node --version | Should -BeLike "v$((Get-ToolsetContent).node.default)*" + } + } } \ No newline at end of file diff --git a/images/win/toolsets/toolset-2016.json b/images/win/toolsets/toolset-2016.json index d5f6ba8f..bb347a2b 100644 --- a/images/win/toolsets/toolset-2016.json +++ b/images/win/toolsets/toolset-2016.json @@ -421,5 +421,8 @@ "args": [ "--installargs", "ADD_CMAKE_TO_PATH=\"System\"" ] } ] + }, + "node": { + "default": "14.18.1" } } diff --git a/images/win/toolsets/toolset-2019.json b/images/win/toolsets/toolset-2019.json index e47f5466..1f34c2f7 100644 --- a/images/win/toolsets/toolset-2019.json +++ b/images/win/toolsets/toolset-2019.json @@ -452,5 +452,8 @@ "args": [ "--installargs", "ADD_CMAKE_TO_PATH=\"System\"" ] } ] + }, + "node": { + "default": "14.18.1" } } diff --git a/images/win/toolsets/toolset-2022.json b/images/win/toolsets/toolset-2022.json index 91f80cef..2343822c 100644 --- a/images/win/toolsets/toolset-2022.json +++ b/images/win/toolsets/toolset-2022.json @@ -289,5 +289,8 @@ "args": [ "--installargs", "ADD_CMAKE_TO_PATH=\"System\"" ] } ] + }, + "node": { + "default": "14.18.1" } }