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

13
nvm.sh
View File

@ -2106,7 +2106,17 @@ nvm_die_on_prefix() {
fi
local NVM_NPM_PREFIX
NVM_NPM_PREFIX="$(npm config --loglevel=warn get prefix)"
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
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
@ -2121,6 +2131,7 @@ nvm_die_on_prefix() {
return 10
fi
fi
fi
}
# Succeeds if $IOJS_VERSION represents an io.js version that has a