make 'install_node' function in 'Node.js' install script simpler, update nvm to 0.38 and fix NVM_DIR again...

pull/708/head
Itai Nelken 3 years ago
parent 8a3e27e039
commit d898d745f3
No known key found for this signature in database
GPG Key ID: E45E4E2C367B8AE6

@ -10,13 +10,7 @@ function error {
function install_node() {
if [[ "$1" == "set_nvm_dir" ]]; then
export NVM_DIR="$2"
fi
if [[ "$3" == "message" || "$1" == message ]]; then
if [[ "$1" == "message" ]]; then
echo "$2"
elif [[ "$3" == message ]]; then
echo "$4"
fi
echo "$3"
fi
nvm install --lts
}
@ -34,10 +28,10 @@ You need to install curl first. If you are on a debian system, this command shou
fi
#Install nvm manager:
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.37.2/install.sh | bash || error "Failed to install nvm!"
export NVM_DIR="$HOME/.config/nvm"
wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh | bash || error "Failed to install nvm!"
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
#Install NodeJS, if nvm fails, try again with a different 'NVM_DIR"
install_node || install_node set_nvm_dir "$HOME/.nvm" message "failed to install node.js! trying again with different NVM_DIR..." || error "Failed to install Node.js using nvm!"
install_node || install_node set_nvm_dir "$HOME/.config/nvm" "failed to install node.js! trying again with different NVM_DIR..." || error "Failed to install Node.js using nvm!"

Loading…
Cancel
Save