diff --git a/images/macos/provision/core/node.sh b/images/macos/provision/core/node.sh index d9136e17..128b4f6f 100644 --- a/images/macos/provision/core/node.sh +++ b/images/macos/provision/core/node.sh @@ -10,9 +10,12 @@ if is_Less_Catalina; then rm -rf "${TMP_FILE}" sudo chown -R $USER "/usr/local/lib/node_modules" else - # Install Node.js 14 for macOS >= 10.15 - brew_smart_install "node@14" - brew link node@14 --force + # Install default Node.js for macOS >= 10.15 + defaultVersion=$(get_toolset_value '.node.default') + + echo "Installing Node.js $defaultVersion" + brew_smart_install "node@$defaultVersion" + brew link node@$defaultVersion --force fi echo Installing yarn... diff --git a/images/macos/provision/core/nvm.sh b/images/macos/provision/core/nvm.sh index 2b80a0b6..16252a02 100755 --- a/images/macos/provision/core/nvm.sh +++ b/images/macos/provision/core/nvm.sh @@ -11,10 +11,10 @@ curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/$VERSION/install.sh | bash if [ $? -eq 0 ]; then . ~/.bashrc nvm --version - nodeVersions=("v10" "v12" "v14") + nodeVersions=$(get_toolset_value '.node.nvm_versions[]') for version in ${nodeVersions[@]} do - nvm install $version + nvm install v${version} done # set system node as default diff --git a/images/macos/tests/Node.Tests.ps1 b/images/macos/tests/Node.Tests.ps1 index d2759adb..baeab046 100644 --- a/images/macos/tests/Node.Tests.ps1 +++ b/images/macos/tests/Node.Tests.ps1 @@ -13,6 +13,10 @@ Describe "Node.js" { "node --version" | Should -ReturnZeroExitCode } + It "Node.js version should correspond to the version in the toolset" { + node --version | Should -BeLike "v$(Get-ToolsetValue 'node.default')*" + } + It "Node.js $expectedNodeVersion is default" { (Get-CommandResult "node --version").Output | Should -BeLike $expectedNodeVersion } diff --git a/images/macos/toolsets/toolset-10.14.json b/images/macos/toolsets/toolset-10.14.json index 4db0578a..18cc772b 100644 --- a/images/macos/toolsets/toolset-10.14.json +++ b/images/macos/toolsets/toolset-10.14.json @@ -375,5 +375,13 @@ }, "go": { "default": "1.15" + }, + "node": { + "default": "8", + "nvm_versions": [ + "10", + "12", + "14" + ] } } diff --git a/images/macos/toolsets/toolset-10.15.json b/images/macos/toolsets/toolset-10.15.json index 1cd9f996..5aa1f47e 100644 --- a/images/macos/toolsets/toolset-10.15.json +++ b/images/macos/toolsets/toolset-10.15.json @@ -331,5 +331,13 @@ }, "go": { "default": "1.15" + }, + "node": { + "default": "14", + "nvm_versions": [ + "10", + "12", + "14" + ] } } diff --git a/images/macos/toolsets/toolset-11.json b/images/macos/toolsets/toolset-11.json index 2ce6bcbe..89479c68 100644 --- a/images/macos/toolsets/toolset-11.json +++ b/images/macos/toolsets/toolset-11.json @@ -284,5 +284,13 @@ }, "go": { "default": "1.15" + }, + "node": { + "default": "14", + "nvm_versions": [ + "10", + "12", + "14" + ] } } diff --git a/images/macos/toolsets/toolset-12.json b/images/macos/toolsets/toolset-12.json index 8bd19272..11f3a7ea 100644 --- a/images/macos/toolsets/toolset-12.json +++ b/images/macos/toolsets/toolset-12.json @@ -184,5 +184,13 @@ }, "go": { "default": "1.17" + }, + "node": { + "default": "14", + "nvm_versions": [ + "10", + "12", + "14" + ] } }