Merge e7e5b372e9 into 3fea5493a4
This commit is contained in:
commit
3fff06a827
6
nvm.sh
6
nvm.sh
|
|
@ -328,6 +328,12 @@ nvm_tree_contains_path() {
|
||||||
|
|
||||||
local pathdir
|
local pathdir
|
||||||
pathdir=$(dirname "${node_path}")
|
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
|
while [ "${pathdir}" != "" ] && [ "${pathdir}" != "." ] && [ "${pathdir}" != "/" ] && [ "${pathdir}" != "${tree}" ]; do
|
||||||
pathdir=$(dirname "${pathdir}")
|
pathdir=$(dirname "${pathdir}")
|
||||||
done
|
done
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,8 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
cleanup () {
|
cleanup () {
|
||||||
|
rm tmp3/tmp2
|
||||||
|
rmdir tmp3
|
||||||
rm tmp/node
|
rm tmp/node
|
||||||
rmdir tmp
|
rmdir tmp
|
||||||
rm tmp2/node
|
rm tmp2/node
|
||||||
|
|
@ -14,6 +16,8 @@ mkdir -p tmp
|
||||||
touch tmp/node
|
touch tmp/node
|
||||||
mkdir -p tmp2
|
mkdir -p tmp2
|
||||||
touch tmp2/node
|
touch tmp2/node
|
||||||
|
mkdir -p tmp3
|
||||||
|
ln -s tmp2 tmp3/
|
||||||
|
|
||||||
[ "$(nvm_tree_contains_path 2>&1)" = "both the tree and the node path are required" ] || die 'incorrect error message with no args'
|
[ "$(nvm_tree_contains_path 2>&1)" = "both the tree and the node path are required" ] || die 'incorrect error message with no args'
|
||||||
[ "$(nvm_tree_contains_path > /dev/null 2>&1 ; echo $?)" = "2" ] || die 'incorrect error code with no args'
|
[ "$(nvm_tree_contains_path > /dev/null 2>&1 ; echo $?)" = "2" ] || die 'incorrect error code with no args'
|
||||||
|
|
@ -28,4 +32,6 @@ nvm_tree_contains_path tmp2 tmp2/node || die '"tmp2" should contain "tmp2/node"'
|
||||||
|
|
||||||
nvm_tree_contains_path tmp2 tmp/node && die '"tmp2" should not contain "tmp/node"'
|
nvm_tree_contains_path tmp2 tmp/node && die '"tmp2" should not contain "tmp/node"'
|
||||||
|
|
||||||
|
nvm_tree_contains_path tmp2 tmp3 && die 'no idea'
|
||||||
|
|
||||||
cleanup
|
cleanup
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue