From 0e9fde7f3187a5937c40e7875d1a96a560b70ff6 Mon Sep 17 00:00:00 2001 From: Brock Angelo Date: Fri, 14 Dec 2018 20:02:01 -0600 Subject: [PATCH 1/3] fixes #46 --- node-reinstall | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/node-reinstall b/node-reinstall index c7c6cc8..4a0d8fd 100755 --- a/node-reinstall +++ b/node-reinstall @@ -3,7 +3,7 @@ # credit: http://stackoverflow.com/a/11178106/2083544 ## program version -VERSION="0.0.17" +VERSION="0.0.18" ## path prefix PREFIX="${PREFIX:-/usr/local}" @@ -185,9 +185,12 @@ sudo rm -rf $PREFIX/lib/dtrace/node.d if (( $USE_NVM )); then # go home and install NVM just because I feel safe there cd $HOME - # get the latest stable version number of nvm from the repo's homepage - [ "$STABLE" == "" ] && STABLE=$(curl -s -k https://github.com/creationix/nvm/ | grep "curl https://raw.githubusercontent.com/creationix/nvm/" | grep -oE "v\d+\.\d+\.\d+") - [[ $STABLE =~ ^v[0-9]+.[0-9]+.[0-9]+$ ]] || STABLE="v0.25.1" + # get the latest stable version number of nvm from the repo's package.json + # credit to https://unix.stackexchange.com/a/166360/107211 and + # credit to https://stackoverflow.com/a/6852427/2083544 + [ "$STABLE" == "" ] && STABLE_WITHOUT_V=$(curl -v --silent https://raw.githubusercontent.com/creationix/nvm/master/package.json 2>&1 | grep -Eo '"version":.*?[^\\]",' | perl -pe 's/"version": //; s/^"//; s/",$//') + [ -n $STABLE_WITHOUT_V ] && [[ $STABLE_WITHOUT_V =~ ^[0-9]+.[0-9]+.[0-9]+$ ]] && STABLE="v${STABLE_WITHOUT_V}" + [[ $STABLE =~ ^v[0-9]+.[0-9]+.[0-9]+$ ]] || STABLE="v0.33.11" curl -sL https://raw.githubusercontent.com/creationix/nvm/$STABLE/install.sh | bash source $HOME/.nvm/nvm.sh elif (( $USE_NAVE )); then From 44e7862d9760ce99ba0c31a135884c9a50a558cb Mon Sep 17 00:00:00 2001 From: Brock Angelo Date: Fri, 14 Dec 2018 20:02:45 -0600 Subject: [PATCH 2/3] fixes #38 --- node-reinstall | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/node-reinstall b/node-reinstall index 4a0d8fd..0f09a25 100755 --- a/node-reinstall +++ b/node-reinstall @@ -105,7 +105,7 @@ confirm () sudo -v # if node is installed, get the installed version -INSTALLED_NODE_VERSION=$(node --version 2> /dev/null) +INSTALLED_NODE_VERSION=$(node --version 2&1> /dev/null) if [[ ! -z $INSTALLED_NODE_VERSION ]]; then echo "Found a version of Node.js that is already installed." echo "If you continue now, we will re-install Node.js version $INSTALLED_NODE_VERSION" From 53c920dd11818a16b05c6defd1deaa1646150422 Mon Sep 17 00:00:00 2001 From: Brock Angelo Date: Fri, 14 Dec 2018 20:03:05 -0600 Subject: [PATCH 3/3] fixes #45 --- node-reinstall | 3 +++ 1 file changed, 3 insertions(+) diff --git a/node-reinstall b/node-reinstall index 0f09a25..94467cb 100755 --- a/node-reinstall +++ b/node-reinstall @@ -182,6 +182,9 @@ sudo rm -rf $PREFIX/bin/{node,npm} sudo rm -rf $PREFIX/share/man/man1/node.1 sudo rm -rf $PREFIX/lib/dtrace/node.d +# remove global node_modules on arch +[ -d /usr/lib/node_modules ] && sudo rm -rf /usr/lib/node_modules + if (( $USE_NVM )); then # go home and install NVM just because I feel safe there cd $HOME