|
|
|
@ -66,7 +66,8 @@ install_nvm_as_script() {
@@ -66,7 +66,8 @@ install_nvm_as_script() {
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if [ -z "$METHOD" ]; then |
|
|
|
|
nvm_do_install() { |
|
|
|
|
if [ -z "$METHOD" ]; then |
|
|
|
|
# Autodetect install method |
|
|
|
|
if nvm_has "git"; then |
|
|
|
|
install_nvm_from_git |
|
|
|
@ -76,24 +77,24 @@ if [ -z "$METHOD" ]; then
@@ -76,24 +77,24 @@ if [ -z "$METHOD" ]; then
|
|
|
|
|
echo >&2 "You need git, curl, or wget to install nvm" |
|
|
|
|
exit 1 |
|
|
|
|
fi |
|
|
|
|
elif [ "~$METHOD" = "~git" ]; then |
|
|
|
|
elif [ "~$METHOD" = "~git" ]; then |
|
|
|
|
if ! nvm_has "git"; then |
|
|
|
|
echo >&2 "You need git to install nvm" |
|
|
|
|
exit 1 |
|
|
|
|
fi |
|
|
|
|
install_nvm_from_git |
|
|
|
|
elif [ "~$METHOD" = "~script" ]; then |
|
|
|
|
elif [ "~$METHOD" = "~script" ]; then |
|
|
|
|
if ! nvm_has "nvm_download"; then |
|
|
|
|
echo >&2 "You need curl or wget to install nvm" |
|
|
|
|
exit 1 |
|
|
|
|
fi |
|
|
|
|
install_nvm_as_script |
|
|
|
|
fi |
|
|
|
|
fi |
|
|
|
|
|
|
|
|
|
echo |
|
|
|
|
echo |
|
|
|
|
|
|
|
|
|
# Detect profile file if not specified as environment variable (eg: PROFILE=~/.myprofile). |
|
|
|
|
if [ -z "$PROFILE" ]; then |
|
|
|
|
# Detect profile file if not specified as environment variable (eg: PROFILE=~/.myprofile). |
|
|
|
|
if [ -z "$PROFILE" ]; then |
|
|
|
|
if [ -f "$HOME/.bashrc" ]; then |
|
|
|
|
PROFILE="$HOME/.bashrc" |
|
|
|
|
elif [ -f "$HOME/.bash_profile" ]; then |
|
|
|
@ -103,11 +104,11 @@ if [ -z "$PROFILE" ]; then
@@ -103,11 +104,11 @@ if [ -z "$PROFILE" ]; then
|
|
|
|
|
elif [ -f "$HOME/.profile" ]; then |
|
|
|
|
PROFILE="$HOME/.profile" |
|
|
|
|
fi |
|
|
|
|
fi |
|
|
|
|
fi |
|
|
|
|
|
|
|
|
|
SOURCE_STR="\nexport NVM_DIR=\"$NVM_DIR\"\n[ -s \"\$NVM_DIR/nvm.sh\" ] && . \"\$NVM_DIR/nvm.sh\" # This loads nvm" |
|
|
|
|
SOURCE_STR="\nexport NVM_DIR=\"$NVM_DIR\"\n[ -s \"\$NVM_DIR/nvm.sh\" ] && . \"\$NVM_DIR/nvm.sh\" # This loads nvm" |
|
|
|
|
|
|
|
|
|
if [ -z "$PROFILE" ] || [ ! -f "$PROFILE" ] ; then |
|
|
|
|
if [ -z "$PROFILE" ] || [ ! -f "$PROFILE" ] ; then |
|
|
|
|
if [ -z "$PROFILE" ]; then |
|
|
|
|
echo "=> Profile not found. Tried ~/.bashrc, ~/.bash_profile, ~/.zshrc, and ~/.profile." |
|
|
|
|
echo "=> Create one of them and run this script again" |
|
|
|
@ -119,13 +120,25 @@ if [ -z "$PROFILE" ] || [ ! -f "$PROFILE" ] ; then
@@ -119,13 +120,25 @@ if [ -z "$PROFILE" ] || [ ! -f "$PROFILE" ] ; then
|
|
|
|
|
echo "=> Append the following lines to the correct file yourself:" |
|
|
|
|
printf "$SOURCE_STR" |
|
|
|
|
echo |
|
|
|
|
else |
|
|
|
|
else |
|
|
|
|
if ! grep -qc 'nvm.sh' "$PROFILE"; then |
|
|
|
|
echo "=> Appending source string to $PROFILE" |
|
|
|
|
printf "$SOURCE_STR\n" >> "$PROFILE" |
|
|
|
|
else |
|
|
|
|
echo "=> Source string already in $PROFILE" |
|
|
|
|
fi |
|
|
|
|
fi |
|
|
|
|
fi |
|
|
|
|
|
|
|
|
|
echo "=> Close and reopen your terminal to start using nvm" |
|
|
|
|
nvm_reset |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
# |
|
|
|
|
# Unsets the various functions defined |
|
|
|
|
# during the execution of the install script |
|
|
|
|
# |
|
|
|
|
nvm_reset() { |
|
|
|
|
unset -f nvm_do_install nvm_has nvm_download install_nvm_as_script install_nvm_from_git nvm_reset |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
echo "=> Close and reopen your terminal to start using nvm" |
|
|
|
|
[ "_$NVM_ENV" = "_testing" ] || nvm_do_install |
|
|
|
|