Browse Source

Merge pull request #2182 from return42/fix-make-nvm

[fix] make nvm.env exit with error when VERBOSE is unset
Markus Heiser 2 years ago
parent
commit
7cbfa6a8dd
1 changed files with 6 additions and 1 deletions
  1. 6 1
      utils/lib_nvm.sh

+ 6 - 1
utils/lib_nvm.sh

@@ -27,6 +27,7 @@ nvm.env() {
     source "${NVM_DIR}/nvm.sh"
     source "${NVM_DIR}/nvm.sh"
     source "${NVM_DIR}/bash_completion"
     source "${NVM_DIR}/bash_completion"
     [ "$VERBOSE" = "1" ] && info_msg "sourced NVM environment from ${NVM_DIR}"
     [ "$VERBOSE" = "1" ] && info_msg "sourced NVM environment from ${NVM_DIR}"
+    return 0
 }
 }
 
 
 nvm.is_installed() {
 nvm.is_installed() {
@@ -102,11 +103,15 @@ EOF
 nvm.install() {
 nvm.install() {
     local NVM_VERSION_TAG
     local NVM_VERSION_TAG
     info_msg "install (update) NVM at ${NVM_DIR}"
     info_msg "install (update) NVM at ${NVM_DIR}"
-    if [[ -d "${NVM_DIR}" ]] ; then
+    if nvm.is_installed; then
         info_msg "already cloned at: ${NVM_DIR}"
         info_msg "already cloned at: ${NVM_DIR}"
         pushd "${NVM_DIR}" &> /dev/null
         pushd "${NVM_DIR}" &> /dev/null
         git fetch --all | prefix_stdout "  ${_Yellow}||${_creset} "
         git fetch --all | prefix_stdout "  ${_Yellow}||${_creset} "
     else
     else
+        # delete any leftovers from previos installations
+        if nvm.is_local; then
+            rm -rf "${NVM_DIR}"
+        fi
         info_msg "clone: ${NVM_GIT_URL}"
         info_msg "clone: ${NVM_GIT_URL}"
         git clone "${NVM_GIT_URL}" "${NVM_DIR}" 2>&1 | prefix_stdout "  ${_Yellow}||${_creset} "
         git clone "${NVM_GIT_URL}" "${NVM_DIR}" 2>&1 | prefix_stdout "  ${_Yellow}||${_creset} "
         pushd "${NVM_DIR}" &> /dev/null
         pushd "${NVM_DIR}" &> /dev/null