[Fix] `nvm_tree_contains_path`: handle symbolic links

Co-Authored-By: Charlie Hileman <aiquicorp@gmail.com>
Co-Authored-By: Jordan Harband <ljharb@gmail.com>
This commit is contained in:
Charlie Hileman 2020-01-08 12:06:49 -05:00 committed by Jordan Harband
parent a1ad32e9cb
commit ab7b4daf17
No known key found for this signature in database
GPG Key ID: 9F6A681E35EF8B56
1 changed files with 6 additions and 0 deletions

6
nvm.sh
View File

@ -311,6 +311,12 @@ nvm_tree_contains_path() {
local pathdir
pathdir=$(dirname "${node_path}")
# get real directory in case of symbolic links
if [ -d "${pathdir-}" ]; then
pathdir="$(nvm_cd -P "${pathdir}" && pwd)"
fi
while [ "${pathdir}" != "" ] && [ "${pathdir}" != "." ] && [ "${pathdir}" != "/" ] && [ "${pathdir}" != "${tree}" ]; do
pathdir=$(dirname "${pathdir}")
done