forked from coolaj86/node-installer.sh
derive $node_install_path from $NODE_PATH
This commit is contained in:
parent
c3e6fa9660
commit
85ad20281f
|
@ -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_VER=${1}
|
||||||
NODEJS_VERT=$(echo ${NODEJS_VER} | cut -c 2- | cut -d '.' -f1)
|
NODEJS_VERT=$(echo ${NODEJS_VER} | cut -c 2- | cut -d '.' -f1)
|
||||||
|
|
||||||
|
@ -12,14 +28,27 @@ then
|
||||||
NODEJS_NAME="iojs"
|
NODEJS_NAME="iojs"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
NODEJS_REMOTE="$NODEJS_BASE_URL/dist/${NODEJS_VER}/${NODEJS_NAME}-${NODEJS_VER}.pkg"
|
# When using .pkg
|
||||||
NODEJS_PKG="/tmp/${NODEJS_NAME}-${NODEJS_VER}.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
|
if [ -n "${NODEJS_VER}" ]; then
|
||||||
echo "installing ${NODEJS_NAME} as ${NODEJS_NAME} ${NODEJS_VER}..."
|
echo "installing ${NODEJS_NAME} as ${NODEJS_NAME} ${NODEJS_VER}..."
|
||||||
curl -fsSL "${NODEJS_REMOTE}" -o "${NODEJS_PKG}"
|
curl -fsSL "${NODEJS_REMOTE}" -o "${NODEJS_PKG}"
|
||||||
sudo /usr/sbin/installer -pkg "${NODEJS_PKG}" -target /
|
|
||||||
|
|
||||||
sudo chown -R $(whoami) /usr/local/lib/node_modules/
|
# When using .pkg
|
||||||
sudo chown $(whoami) /usr/local/bin/
|
#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
|
fi
|
||||||
|
|
Loading…
Reference in New Issue