remove npm dependency for prefix check

This commit is contained in:
Tobias Gurtzick 2017-08-26 22:20:03 +02:00
parent cf5272e1a0
commit 2e6e512fd5
No known key found for this signature in database
GPG Key ID: 6C56E4E3D2EAC901

39
nvm.sh
View File

@ -2106,21 +2106,32 @@ nvm_die_on_prefix() {
fi
local NVM_NPM_PREFIX
NVM_NPM_PREFIX="$(npm config --loglevel=warn 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 delete prefix
else
nvm deactivate >/dev/null 2>&1
nvm_err "nvm is not compatible with the npm config \"prefix\" option: currently set to \"$NVM_NPM_PREFIX\""
if nvm_has 'npm'; then
nvm_err "Run \`npm config delete prefix\` or \`$NVM_COMMAND\` to unset it."
else
nvm_err "Run \`$NVM_COMMAND\` to unset it."
fi
return 10
declare -a npmrcs=("." "$HOME")
for npmrc in "${npmrcs[@]}"; do
if [ -f "${npmrc}/.npmrc" ]; then
NVM_NPM_PREFIX=$(grep ^prefix= ${npmrc}/.npmrc | sed s/prefix=\\\(.*\\\)$/\\1/)
break
fi
fi
done
if [[ -n $NVM_NPM_PREFIX ]]; then
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 delete prefix
else
nvm deactivate >/dev/null 2>&1
nvm_err "nvm is not compatible with the npm config \"prefix\" option: currently set to \"$NVM_NPM_PREFIX\""
if nvm_has 'npm'; then
nvm_err "Run \`npm config delete prefix\` or \`$NVM_COMMAND\` to unset it."
else
nvm_err "Run \`$NVM_COMMAND\` to unset it."
fi
return 10
fi
fi
fi
}
# Succeeds if $IOJS_VERSION represents an io.js version that has a