[Fix] `install`: Ignore npm command under $NVM_DIR when checking for global modules
parent
ed321f1df0
commit
d4eba354b5
|
@ -262,7 +262,9 @@ nvm_detect_profile() {
|
|||
# Node, and warn them if so.
|
||||
#
|
||||
nvm_check_global_modules() {
|
||||
command -v npm >/dev/null 2>&1 || return 0
|
||||
local NPM_COMMAND
|
||||
NPM_COMMAND="$(command -v npm 2>/dev/null)" || return 0
|
||||
[ -n "${NVM_DIR}" ] && [ -z "${NPM_COMMAND%%$NVM_DIR/*}" ] && return 0
|
||||
|
||||
local NPM_VERSION
|
||||
NPM_VERSION="$(npm --version)"
|
||||
|
|
|
@ -6,9 +6,10 @@ cleanup () {
|
|||
|
||||
rm -f npm
|
||||
PATH="$ORIGINAL_PATH"
|
||||
NVM_DIR="$ORIGINAL_NVM_DIR"
|
||||
|
||||
unset -f setup cleanup die
|
||||
unset message ORIGINAL_PATH
|
||||
unset message ORIGINAL_PATH ORIGINAL_NVM_DIR
|
||||
}
|
||||
die () { echo "$@" ; cleanup ; exit 1; }
|
||||
|
||||
|
@ -16,6 +17,10 @@ NVM_ENV=testing \. ../../install.sh
|
|||
|
||||
setup () {
|
||||
ORIGINAL_PATH="$PATH"
|
||||
ORIGINAL_NVM_DIR="$NVM_DIR"
|
||||
|
||||
# Pretend we're not using NVM
|
||||
unset NVM_DIR
|
||||
|
||||
npm_config_prefix="$(pwd)"
|
||||
export npm_config_prefix
|
||||
|
@ -29,6 +34,10 @@ npm install -g nop >/dev/null || die 'nvm_check_global_modules cannot be tested
|
|||
message=$(nvm_check_global_modules)
|
||||
[ ! -z "$message" ] || die "nvm_check_global_modules should have printed a notice when npm had global modules installed"
|
||||
|
||||
# Admit we're using NVM, just for this one test
|
||||
message=$(NVM_DIR=$ORIGINAL_NVM_DIR nvm_check_global_modules)
|
||||
[ -z "$message" ] || die "nvm_check_global_modules should not have printed a notice when npm is managed by nvm"
|
||||
|
||||
npm uninstall -g nop >/dev/null
|
||||
message=$(nvm_check_global_modules)
|
||||
[ -z "$message" ] || die "nvm_check_global_modules should not have printed a notice when npm had no global modules installed"
|
||||
|
|
Loading…
Reference in New Issue