From c7ac69bfbb677b17f0f50f885c072da3004530c9 Mon Sep 17 00:00:00 2001 From: Ahmad Magdy Date: Thu, 30 Nov 2017 14:47:42 +0100 Subject: [PATCH 1/3] Fix nvm_install_node function in install.sh script to not override the actual NODE_VERSION value --- install.sh | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/install.sh b/install.sh index e0d793e..120c98a 100755 --- a/install.sh +++ b/install.sh @@ -140,22 +140,22 @@ install_nvm_from_git() { # Automatically install Node.js # nvm_install_node() { - local NODE_VERSION - NODE_VERSION="$(nvm_node_version)" + local NODE_VERSION_LOCAL + NODE_VERSION_LOCAL="$(nvm_node_version)" - if [ -z "$NODE_VERSION" ]; then + if [ -z "$NODE_VERSION_LOCAL" ]; then return 0 fi - echo "=> Installing Node.js version $NODE_VERSION" - nvm install "$NODE_VERSION" + echo "=> Installing Node.js version $NODE_VERSION_LOCAL" + nvm install "$NODE_VERSION_LOCAL" local CURRENT_NVM_NODE CURRENT_NVM_NODE="$(nvm_version current)" - if [ "$(nvm_version "$NODE_VERSION")" == "$CURRENT_NVM_NODE" ]; then - echo "=> Node.js version $NODE_VERSION has been successfully installed" + if [ "$(nvm_version "$NODE_VERSION_LOCAL")" == "$CURRENT_NVM_NODE" ]; then + echo "=> Node.js version $NODE_VERSION_LOCAL has been successfully installed" else - echo >&2 "Failed to install Node.js $NODE_VERSION" + echo >&2 "Failed to install Node.js $NODE_VERSION_LOCAL" fi } From 4b0563093c697c5ca5fd67bfa68a8457004670c5 Mon Sep 17 00:00:00 2001 From: Ahmad Magdy Date: Thu, 30 Nov 2017 15:23:37 +0100 Subject: [PATCH 2/3] Add test nvm_install_with_node_version under test/install_script --- test/install_script/nvm_install_with_node_version | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100755 test/install_script/nvm_install_with_node_version diff --git a/test/install_script/nvm_install_with_node_version b/test/install_script/nvm_install_with_node_version new file mode 100755 index 0000000..e88ab2b --- /dev/null +++ b/test/install_script/nvm_install_with_node_version @@ -0,0 +1,8 @@ +#!/bin/sh + +die () { echo "$@" ; exit 1; } + +NODE_VERSION=8 \. ../../install.sh + +# nvm installed node 8 +(nvm ls | grep 8) > /dev/null 2>&1 || die "nvm didn't install node 8" From bacdd955918949d35b16bf0936de8b428f862795 Mon Sep 17 00:00:00 2001 From: Ahmad Magdy Date: Thu, 30 Nov 2017 15:33:01 +0100 Subject: [PATCH 3/3] Update test/install_script/nvm_install_with_node_version to use nvm ls 8 instead of grep! --- test/install_script/nvm_install_with_node_version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/install_script/nvm_install_with_node_version b/test/install_script/nvm_install_with_node_version index e88ab2b..5f5208f 100755 --- a/test/install_script/nvm_install_with_node_version +++ b/test/install_script/nvm_install_with_node_version @@ -5,4 +5,4 @@ die () { echo "$@" ; exit 1; } NODE_VERSION=8 \. ../../install.sh # nvm installed node 8 -(nvm ls | grep 8) > /dev/null 2>&1 || die "nvm didn't install node 8" +nvm ls 8 > /dev/null 2>&1 || die "nvm didn't install node 8"