Merge pull request #1986 from Sayegh7/master
[Fix] Make installation less restrictive when NVM_DIR is set
commit
66d2909650
29
install.sh
29
install.sh
|
@ -6,16 +6,22 @@ nvm_has() {
|
||||||
type "$1" > /dev/null 2>&1
|
type "$1" > /dev/null 2>&1
|
||||||
}
|
}
|
||||||
|
|
||||||
nvm_install_dir() {
|
nvm_default_install_dir() {
|
||||||
if [ -n "$NVM_DIR" ]; then
|
if [ -n "$XDG_CONFIG_HOME" ]; then
|
||||||
printf %s "${NVM_DIR}"
|
|
||||||
elif [ -n "$XDG_CONFIG_HOME" ]; then
|
|
||||||
printf %s "${XDG_CONFIG_HOME/nvm}"
|
printf %s "${XDG_CONFIG_HOME/nvm}"
|
||||||
else
|
else
|
||||||
printf %s "$HOME/.nvm"
|
printf %s "$HOME/.nvm"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
nvm_install_dir() {
|
||||||
|
if [ -n "$NVM_DIR" ]; then
|
||||||
|
printf %s "${NVM_DIR}"
|
||||||
|
else
|
||||||
|
nvm_default_install_dir
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
nvm_latest_version() {
|
nvm_latest_version() {
|
||||||
echo "v0.34.0"
|
echo "v0.34.0"
|
||||||
}
|
}
|
||||||
|
@ -304,8 +310,17 @@ nvm_check_global_modules() {
|
||||||
|
|
||||||
nvm_do_install() {
|
nvm_do_install() {
|
||||||
if [ -n "${NVM_DIR-}" ] && ! [ -d "${NVM_DIR}" ]; then
|
if [ -n "${NVM_DIR-}" ] && ! [ -d "${NVM_DIR}" ]; then
|
||||||
echo >&2 "You have \$NVM_DIR set to \"${NVM_DIR}\", but that directory does not exist. Check your profile files and environment."
|
if [ -e "${NVM_DIR}" ]; then
|
||||||
exit 1
|
echo >&2 "File \"${NVM_DIR}\" has the same name as installation directory."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "${NVM_DIR}" = "$(nvm_default_install_dir)" ]; then
|
||||||
|
mkdir "${NVM_DIR}"
|
||||||
|
else
|
||||||
|
echo >&2 "You have \$NVM_DIR set to \"${NVM_DIR}\", but that directory does not exist. Check your profile files and environment."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
if [ -z "${METHOD}" ]; then
|
if [ -z "${METHOD}" ]; then
|
||||||
# Autodetect install method
|
# Autodetect install method
|
||||||
|
@ -406,7 +421,7 @@ nvm_reset() {
|
||||||
unset -f nvm_has nvm_install_dir nvm_latest_version nvm_profile_is_bash_or_zsh \
|
unset -f nvm_has nvm_install_dir nvm_latest_version nvm_profile_is_bash_or_zsh \
|
||||||
nvm_source nvm_node_version nvm_download install_nvm_from_git nvm_install_node \
|
nvm_source nvm_node_version nvm_download install_nvm_from_git nvm_install_node \
|
||||||
install_nvm_as_script nvm_try_profile nvm_detect_profile nvm_check_global_modules \
|
install_nvm_as_script nvm_try_profile nvm_detect_profile nvm_check_global_modules \
|
||||||
nvm_do_install nvm_reset
|
nvm_do_install nvm_reset nvm_default_install_dir
|
||||||
}
|
}
|
||||||
|
|
||||||
[ "_$NVM_ENV" = "_testing" ] || nvm_do_install
|
[ "_$NVM_ENV" = "_testing" ] || nvm_do_install
|
||||||
|
|
Loading…
Reference in New Issue