Created
March 27, 2017 15:30
-
-
Save deiga/0087c0b7c5b9dc59a9120e29479f058c to your computer and use it in GitHub Desktop.
Node installation script with bash
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function install_node() { | |
local REQUIRED_MAJOR_NODE_VERSION=${REQUIRED_NODEJS_VERSION:0:1} | |
echo "${BLUE}Which version manager do you want to install node.js with? If you don't know, choose 'brew'${NORMAL}:" | |
select NODE_VERSION_MANAGER in 'brew' 'nvm' 'nodenv' 'other'; | |
do | |
case $NODE_VERSION_MANAGER in | |
'nvm'|'nodenv') | |
verify_command $NODE_VERSION_MANAGER | |
set +x | |
$NODE_VERSION_MANAGER install $REQUIRED_MAJOR_NODE_VERSION | |
set -x | |
break | |
;; | |
'other') | |
read -p "${BLUE}Please write the command of your node version manager: ${NORMAL}" -r | |
local OTHER=$REPLY | |
if ! command -v "$OTHER"; then | |
echo "${RED}$OTHER does not exist.$NORMAL" >&2 | |
install_node_homebrew | |
else | |
${OTHER} install $REQUIRED_MAJOR_NODE_VERSION | |
fi | |
break | |
;; | |
'brew'|*) | |
install_node_homebrew | |
break | |
;; | |
esac | |
done | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment