From 5f33b32a1e3f80fef13cf8527d1b96b1d269a1fe Mon Sep 17 00:00:00 2001 From: Nikolay Frolov <90333448+nikolai-frolov@users.noreply.github.com> Date: Sat, 30 Oct 2021 14:56:36 +0300 Subject: [PATCH] [Linux] Rework NodeJS install (#4378) --- images/linux/scripts/installers/nodejs.sh | 7 +++++-- images/linux/scripts/tests/Node.Tests.ps1 | 4 ++++ images/linux/toolsets/toolset-1804.json | 3 +++ images/linux/toolsets/toolset-2004.json | 3 +++ 4 files changed, 15 insertions(+), 2 deletions(-) diff --git a/images/linux/scripts/installers/nodejs.sh b/images/linux/scripts/installers/nodejs.sh index aa6eaff1c..bbf89a67a 100644 --- a/images/linux/scripts/installers/nodejs.sh +++ b/images/linux/scripts/installers/nodejs.sh @@ -7,9 +7,12 @@ # Source the helpers for use with the script source $HELPER_SCRIPTS/install.sh -# Install LTS Node.js and related build tools +# Install default Node.js +defaultVersion=$(get_toolset_value '.node.default') +# TODO: Usage of "githubusercontent.com/mklement0" doesn't look like a correct approach. Need to correct it according to the official Node.js docs. curl -sL https://raw.githubusercontent.com/mklement0/n-install/stable/bin/n-install | bash -s -- -ny - -~/n/bin/n lts +~/n/bin/n $defaultVersion + # Install node modules node_modules=$(get_toolset_value '.node_modules[].name') diff --git a/images/linux/scripts/tests/Node.Tests.ps1 b/images/linux/scripts/tests/Node.Tests.ps1 index 06790bdf1..10d8e35d6 100644 --- a/images/linux/scripts/tests/Node.Tests.ps1 +++ b/images/linux/scripts/tests/Node.Tests.ps1 @@ -10,5 +10,9 @@ Describe "Node.js" { "$NodeCommand --version" | Should -ReturnZeroExitCode } + + It "Node.js version should correspond to the version in the toolset" { + node --version | Should -BeLike "v$((Get-ToolsetContent).node.default).*" + } } diff --git a/images/linux/toolsets/toolset-1804.json b/images/linux/toolsets/toolset-1804.json index 88692e622..f50232270 100644 --- a/images/linux/toolsets/toolset-1804.json +++ b/images/linux/toolsets/toolset-1804.json @@ -283,6 +283,9 @@ "binary_name": "selenium-server-standalone" }, "rubygems": [], + "node": { + "default": "14" + }, "node_modules": [ { "name": "grunt", diff --git a/images/linux/toolsets/toolset-2004.json b/images/linux/toolsets/toolset-2004.json index d07ef4907..fa07c2910 100644 --- a/images/linux/toolsets/toolset-2004.json +++ b/images/linux/toolsets/toolset-2004.json @@ -283,6 +283,9 @@ "version": "3", "binary_name": "selenium-server-standalone" }, + "node": { + "default": "14" + }, "node_modules": [ { "name": "grunt",