mirror of
https://github.com/lukechilds/zsh-nvm.git
synced 2025-01-30 09:47:14 +08:00
Make sure that it handles cases where there is no global node install
This commit is contained in:
parent
a04d4e5e80
commit
7830783ce9
@ -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
|
||||
|
@ -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).
|
||||
#
|
||||
|
Loading…
Reference in New Issue
Block a user