From 869b273c77a471c68fae711adb84dd74906bb34a Mon Sep 17 00:00:00 2001 From: adabru Date: Thu, 5 May 2016 03:36:30 +0200 Subject: [PATCH] `npm config get prefix` to background --- nvm.sh | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/nvm.sh b/nvm.sh index 9796582..17b6529 100755 --- a/nvm.sh +++ b/nvm.sh @@ -1534,22 +1534,26 @@ nvm_die_on_prefix() { return fi - local NVM_NPM_PREFIX - NVM_NPM_PREFIX="$(NPM_CONFIG_LOGLEVEL=warn npm config get prefix)" - if ! (nvm_tree_contains_path "$NVM_DIR" "$NVM_NPM_PREFIX" >/dev/null 2>&1); then - if [ "_$NVM_DELETE_PREFIX" = "_1" ]; then - NPM_CONFIG_LOGLEVEL=warn npm config delete prefix - else - nvm deactivate >/dev/null 2>&1 - echo >&2 "nvm is not compatible with the npm config \"prefix\" option: currently set to \"$NVM_NPM_PREFIX\"" - if nvm_has 'npm'; then - echo >&2 "Run \`npm config delete prefix\` or \`$NVM_COMMAND\` to unset it." + check_prefix() { + local NVM_NPM_PREFIX + NVM_NPM_PREFIX="$(NPM_CONFIG_LOGLEVEL=warn npm config get prefix 2>&1)" + if ! (nvm_tree_contains_path "$NVM_DIR" "$NVM_NPM_PREFIX" >/dev/null 2>&1); then + if [ "_$NVM_DELETE_PREFIX" = "_1" ]; then + NPM_CONFIG_LOGLEVEL=warn npm config delete prefix else - echo >&2 "Run \`$NVM_COMMAND\` to unset it." + nvm deactivate >/dev/null 2>&1 + echo >&2 "" + echo >&2 "nvm is not compatible with the npm config \"prefix\" option: currently set to \"$NVM_NPM_PREFIX\"" + if nvm_has 'npm'; then + echo >&2 "Run \`npm config delete prefix\` or \`$NVM_COMMAND\` to unset it." + else + echo >&2 "Run \`$NVM_COMMAND\` to unset it." + fi + return 10 fi - return 10 fi - fi + } + (check_prefix &) } # Succeeds if $IOJS_VERSION represents an io.js version that has a