diff --git a/tests/options/NVM_PREFER_LOCAL_BINS b/tests/options/NVM_PREFER_LOCAL_BINS index 4718fc6..0a886a7 100755 --- a/tests/options/NVM_PREFER_LOCAL_BINS +++ b/tests/options/NVM_PREFER_LOCAL_BINS @@ -4,11 +4,7 @@ source ../common.sh # Setup projects in tmp, so we don't have ancestor paths of this repo messing # with things. cd $(mktemp -d) -# npm bin can resolve to a different path (/private/var instead of /var) on some -# platforms. It also resolves to the current directory if there is no -# package.json up the current path. So, we use it to expand our path. -sandbox=$(dirname $(dirname $(npm bin))) -echo "Running NVM_PREFER_LOCAL_BINS in $sandbox\n" +echo "Running NVM_PREFER_LOCAL_BINS in $(pwd)\n" mkdir -p package/src/a/b touch package/package.json @@ -18,8 +14,21 @@ touch package/vendor/package.json # Load it. export NVM_PREFER_LOCAL_BINS=true load_zsh_nvm + +# Check cding without node installed (shouldn't fail) +cd ./package +cd ./src/a/b +cd ../../../.. + +# Now test with node installed +nvm install 8 +nvm use 8 # This is our base path, without any local binary paths in it. base_path=$PATH +# npm bin can resolve to a different path (/private/var instead of /var) on some +# platforms. It also resolves to the current directory if there is no +# package.json up the current path. So, we use it to expand our path. +sandbox=$(dirname $(dirname $(npm bin))) # Check cd directly into a package directory cd ./package diff --git a/zsh-nvm.plugin.zsh b/zsh-nvm.plugin.zsh index 68ec0fd..ee35705 100644 --- a/zsh-nvm.plugin.zsh +++ b/zsh-nvm.plugin.zsh @@ -196,6 +196,7 @@ _zsh_nvm_install_wrapper() { } _zsh_nvm_add_local_bin_path() { + _zsh_nvm_has npm || return # No-op until we have a copy of node in our env. local nearest_package=$(nvm_find_up package.json) # Skip if we're moving within a project (npm bin is slow). #