dev/+js: use nvm to manage node

This commit is contained in:
Henrik Lissner 2017-07-17 13:19:02 +02:00
parent 4ebe18eb8b
commit 48af02684f
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395
3 changed files with 18 additions and 13 deletions

View file

@ -1 +1,4 @@
path=(./node_modules/.bin $path)
export NVM_DIR="$HOME/.nvm"
[[ -s "$NVM_DIR/nvm.sh" ]] && . "$NVM_DIR/nvm.sh"

View file

@ -1,12 +1,10 @@
#!/usr/bin/env bash
case $OSTYPE in
darwin*)
brew install node
;;
linux*)
if [[ -f /etc/arch-release ]]; then
sudo pacman --needed --noconfirm -S nodejs npm
fi
;;
esac
if [[ ! -d ~/.nvm ]]; then
git clone https://github.com/creationix/nvm ~/.nvm
cd $HOME/.nvm && git checkout v0.33.2
export NVM_DIR="$HOME/.nvm"
. $HOME/.nvm/nvm.sh
nvm install node
fi

View file

@ -1,5 +1,9 @@
#!/usr/bin/env bash
npm=$(which npm)
[[ -w $npm ]] || npm="sudo $npm"
$npm -g update
(
cd "$NVM_DIR"
git fetch origin
git checkout $(git describe --abbrev=0 --tags --match "v[0-9]*" origin)
) && . "$NVM_DIR/nvm.sh"
nvm run node update -g