Make sure that it handles cases where there is no global node install

This commit is contained in:
Ian MacLeod 2017-09-04 12:13:50 -07:00
parent a04d4e5e80
commit 7830783ce9
No known key found for this signature in database
GPG Key ID: 4181ED3804601ED6
2 changed files with 15 additions and 5 deletions

View File

@ -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

View File

@ -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).
#