nvm/test/fast/Unit tests/nvm_has
Peter Dave Hello 293c6d198b Use which instead of type to detect if command exists
`type` will not confirm the file in $PATH is executable or not.
2016-11-18 04:03:45 +08:00

13 lines
371 B
Bash
Executable File

#!/bin/sh
die () { echo "$@" ; exit 1; }
\. ../../../nvm.sh
nvm_has cat && command which 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 && ! command which foobarbaz >/dev/null 2>&1 || die "nvm_has does not return a nonzero exit code when not found"