diff --git a/dev/+js/env.zsh b/dev/+js/env.zsh index 690818fd..eba0f19e 100644 --- a/dev/+js/env.zsh +++ b/dev/+js/env.zsh @@ -1 +1,4 @@ path=(./node_modules/.bin $path) + +export NVM_DIR="$HOME/.nvm" +[[ -s "$NVM_DIR/nvm.sh" ]] && . "$NVM_DIR/nvm.sh" diff --git a/dev/+js/install b/dev/+js/install index 7f42bc22..43f5c9c1 100755 --- a/dev/+js/install +++ b/dev/+js/install @@ -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 diff --git a/dev/+js/update b/dev/+js/update index 3b5a408f..ae8c3d98 100755 --- a/dev/+js/update +++ b/dev/+js/update @@ -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