From 94e18f04a90cedb99f67dd2b71af6e8b1b60e08a Mon Sep 17 00:00:00 2001 From: AJ ONeal Date: Mon, 15 May 2017 21:38:48 -0600 Subject: [PATCH] Derive $node_install_path from $NODE_PATH --- setup-node-ubuntu.bash | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/setup-node-ubuntu.bash b/setup-node-ubuntu.bash index 142481c..37d09bd 100644 --- a/setup-node-ubuntu.bash +++ b/setup-node-ubuntu.bash @@ -1,3 +1,11 @@ +#!/bin/bash + +if [ -z "$NODE_PATH" ]; then + node_install_path=$(dirname $(dirname $NODE_PATH)) +else + node_install_path=$PREFIX/usr/local +fi + NODEJS_VER=${1} NODEJS_VERT=$(echo ${NODEJS_VER} | cut -c 2- | cut -d '.' -f1) @@ -45,9 +53,9 @@ if [ -n "${NODEJS_VER}" ]; then mkdir -p ${NODEJS_UNTAR}/ tar xf ${NODEJS_LOCAL} -C ${NODEJS_UNTAR}/ --strip-components=1 rm ${NODEJS_UNTAR}/{LICENSE,CHANGELOG.md,README.md} - sudo rsync -a "${NODEJS_UNTAR}/" /usr/local/ + sudo rsync -a "${NODEJS_UNTAR}/" "$node_install_path" - sudo chown -R $(whoami) /usr/local/lib/node_modules/ - sudo chown $(whoami) /usr/local/bin/ + sudo chown -R $(whoami) "$node_install_path/lib/node_modules/" + sudo chown $(whoami) ""$node_install_path"/bin/" fi