![ljharb@gmail.com](/assets/img/avatar_default.png)
3 changed files with 52 additions and 9 deletions
@ -0,0 +1,26 @@ |
|||||||
|
#!/bin/sh |
||||||
|
|
||||||
|
die () { echo $@ ; cleanup ; exit 1; } |
||||||
|
setup() { |
||||||
|
cleanup |
||||||
|
mkdir -p tmp_nvm_find_up/a/b/c/d |
||||||
|
touch tmp_nvm_find_up/test |
||||||
|
touch tmp_nvm_find_up/a/b/c/test |
||||||
|
} |
||||||
|
cleanup () { |
||||||
|
rm -rf tmp_nvm_find_up |
||||||
|
} |
||||||
|
|
||||||
|
. ../../../nvm.sh |
||||||
|
|
||||||
|
setup |
||||||
|
|
||||||
|
TEST_DIR="$PWD" |
||||||
|
|
||||||
|
[ "~$(PWD=$TEST_DIR/tmp_nvm_find_up/a nvm_find_up 'test')" = "~$TEST_DIR/tmp_nvm_find_up" ] || die "failed to find 1 dir up" |
||||||
|
[ "~$(PWD=$TEST_DIR/tmp_nvm_find_up/a/b nvm_find_up 'test')" = "~$TEST_DIR/tmp_nvm_find_up" ] || die "failed to find 2 dirs up" |
||||||
|
[ "~$(PWD=$TEST_DIR/tmp_nvm_find_up/a/b/c nvm_find_up 'test')" = "~$TEST_DIR/tmp_nvm_find_up/a/b/c" ] || die "failed to find in current dir" |
||||||
|
[ "~$(PWD=$TEST_DIR/tmp_nvm_find_up/a/b/c/d nvm_find_up 'test')" = "~$TEST_DIR/tmp_nvm_find_up/a/b/c" ] || die "failed to find 1 level up from current dir" |
||||||
|
|
||||||
|
cleanup |
||||||
|
|
@ -0,0 +1,12 @@ |
|||||||
|
#!/bin/sh |
||||||
|
|
||||||
|
die () { echo $@ ; exit 1; } |
||||||
|
|
||||||
|
. ../../../nvm.sh |
||||||
|
|
||||||
|
nvm_has cat && type cat > /dev/null || die 'nvm_has locates "cat" properly' |
||||||
|
|
||||||
|
[ "~$(nvm_has foobarbaz 2>&1)" = "~" ] || die "nvm_has does not suppress error output" |
||||||
|
|
||||||
|
! nvm_has foobarbaz && ! type foobarbaz >/dev/null 2>&1 || die "nvm_has does not return a nonzero exit code when not found" |
||||||
|
|
Loading…
Reference in new issue