mirror of
https://github.com/nvm-sh/nvm.git
synced 2025-05-17 17:41:50 +00:00
use $NVM_PROFILE if defined and exists for bashrc modifications. Allows for custom profile configuration. Hide confusing output from git when deleting branch. Added note to user that they can source $NVM_PROFILE to use nvm
This commit is contained in:
parent
b9df3fccb4
commit
b6ebc76654
29
install.sh
29
install.sh
@ -3,7 +3,7 @@
|
|||||||
set -e
|
set -e
|
||||||
|
|
||||||
nvm_has() {
|
nvm_has() {
|
||||||
type "$1" > /dev/null 2>&1
|
type "$1" &> /dev/null
|
||||||
return $?
|
return $?
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -69,7 +69,7 @@ install_nvm_from_git() {
|
|||||||
mkdir -p "$NVM_DIR"
|
mkdir -p "$NVM_DIR"
|
||||||
git clone "$(nvm_source "git")" "$NVM_DIR"
|
git clone "$(nvm_source "git")" "$NVM_DIR"
|
||||||
fi
|
fi
|
||||||
cd "$NVM_DIR" && git checkout v0.20.0 && git branch -D master >/dev/null 2>&1
|
( cd "$NVM_DIR" && git checkout v0.20.0 && git branch -D master ) &>/dev/null
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -107,7 +107,9 @@ install_nvm_as_script() {
|
|||||||
# Otherwise, an empty string is returned
|
# Otherwise, an empty string is returned
|
||||||
#
|
#
|
||||||
nvm_detect_profile() {
|
nvm_detect_profile() {
|
||||||
if [ -f "$PROFILE" ]; then
|
if [ -f "$NVM_PROFILE" ]; then
|
||||||
|
echo "$NVM_PROFILE"
|
||||||
|
elif [ -f "$PROFILE" ]; then
|
||||||
echo "$PROFILE"
|
echo "$PROFILE"
|
||||||
elif [ -f "$HOME/.bashrc" ]; then
|
elif [ -f "$HOME/.bashrc" ]; then
|
||||||
echo "$HOME/.bashrc"
|
echo "$HOME/.bashrc"
|
||||||
@ -147,29 +149,30 @@ nvm_do_install() {
|
|||||||
|
|
||||||
echo
|
echo
|
||||||
|
|
||||||
local NVM_PROFILE
|
local _NVM_PROFILE
|
||||||
NVM_PROFILE=$(nvm_detect_profile)
|
_NVM_PROFILE="$(nvm_detect_profile)"
|
||||||
|
|
||||||
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 "$NVM_PROFILE" ] ; then
|
if [ -z "$_NVM_PROFILE" ] ; then
|
||||||
echo "=> Profile not found. Tried $NVM_PROFILE (as defined in \$PROFILE), ~/.bashrc, ~/.bash_profile, ~/.zshrc, and ~/.profile."
|
echo "=> Profile not found. Tried $_NVM_PROFILE (as defined in \$PROFILE), ~/.bashrc, ~/.bash_profile, ~/.zshrc, and ~/.profile."
|
||||||
echo "=> Create one of them and run this script again"
|
echo "=> Create one of them and run this script again"
|
||||||
echo "=> Create it (touch $NVM_PROFILE) and run this script again"
|
echo "=> Create it (touch $_NVM_PROFILE) and run this script again"
|
||||||
echo " OR"
|
echo " OR"
|
||||||
echo "=> Append the following lines to the correct file yourself:"
|
echo "=> Append the following lines to the correct file yourself:"
|
||||||
printf "$SOURCE_STR"
|
printf "$SOURCE_STR"
|
||||||
echo
|
echo
|
||||||
else
|
else
|
||||||
if ! grep -qc 'nvm.sh' "$NVM_PROFILE"; then
|
if ! grep -qc 'nvm.sh' "$_NVM_PROFILE"; then
|
||||||
echo "=> Appending source string to $NVM_PROFILE"
|
echo "=> Appending source string to $_NVM_PROFILE"
|
||||||
printf "$SOURCE_STR\n" >> "$NVM_PROFILE"
|
printf "$SOURCE_STR\n" >> "$_NVM_PROFILE"
|
||||||
else
|
else
|
||||||
echo "=> Source string already in $NVM_PROFILE"
|
echo "=> Source string already in $_NVM_PROFILE"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "=> Close and reopen your terminal to start using nvm"
|
echo "=> Close and reopen your terminal to start using nvm, or"
|
||||||
|
echo "=> source $_NVM_PROFILE"
|
||||||
nvm_reset
|
nvm_reset
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user