From 85ad20281f2abaa963a20366b0fbf544bdb8187e Mon Sep 17 00:00:00 2001 From: AJ ONeal Date: Mon, 15 May 2017 21:53:39 -0600 Subject: [PATCH] derive $node_install_path from $NODE_PATH --- setup-node-mavericks.bash | 39 ++++++++++++++++++++++++++++++++++----- 1 file changed, 34 insertions(+), 5 deletions(-) diff --git a/setup-node-mavericks.bash b/setup-node-mavericks.bash index f02639c..6b98fe7 100644 --- a/setup-node-mavericks.bash +++ b/setup-node-mavericks.bash @@ -1,3 +1,19 @@ +#!/bin/bash + +set -e +set -u +set -o pipefail + +if [ -z "${PREFIX-}" ]; then + PREFIX="" +fi + +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) @@ -12,14 +28,27 @@ then NODEJS_NAME="iojs" fi -NODEJS_REMOTE="$NODEJS_BASE_URL/dist/${NODEJS_VER}/${NODEJS_NAME}-${NODEJS_VER}.pkg" -NODEJS_PKG="/tmp/${NODEJS_NAME}-${NODEJS_VER}.pkg" +# When using .pkg +#NODEJS_REMOTE="$NODEJS_BASE_URL/dist/${NODEJS_VER}/${NODEJS_NAME}-${NODEJS_VER}.pkg" +#NODEJS_PKG="/tmp/${NODEJS_NAME}-${NODEJS_VER}.pkg" + +NODEJS_REMOTE="$NODEJS_BASE_URL/dist/${NODEJS_VER}/${NODEJS_NAME}-${NODEJS_VER}.tar.gz" +NODEJS_PKG="/tmp/${NODEJS_NAME}-${NODEJS_VER}-darwin-x64.tar.gz" +NODEJS_UNTAR="/tmp/${NODEJS_NAME}-${NODEJS_VER}-darwin-x64" if [ -n "${NODEJS_VER}" ]; then echo "installing ${NODEJS_NAME} as ${NODEJS_NAME} ${NODEJS_VER}..." curl -fsSL "${NODEJS_REMOTE}" -o "${NODEJS_PKG}" - sudo /usr/sbin/installer -pkg "${NODEJS_PKG}" -target / - sudo chown -R $(whoami) /usr/local/lib/node_modules/ - sudo chown $(whoami) /usr/local/bin/ + # When using .pkg + #sudo /usr/sbin/installer -pkg "${NODEJS_PKG}" -target / + + # When using .tar.gz + sudo tar xf "${NODEJS_PKG}" -C "{NODEJS_UNTAR}/" + rm -f ${NODEJS_UNTAR}/{LICENSE,CHANGELOG.md,README.md} + sudo rsync -a "${NODEJS_UNTAR}/" "$node_install_path/" + + + sudo chown -R $(whoami) "$node_install_path/lib/node_modules/" + sudo chown $(whoami) "$node_install_path/bin/" fi