nvm_source
This file
Path
test/install_script/nvm_source
40 lines · 1.8 KiB
Last changed by
Not known.
History of this fileTake it
1#!/bin/sh23cleanup () {4 unset -f die cleanup5 unset NVM_SOURCE out6}7die () { echo $@ ; cleanup ; exit 1; }89NVM_ENV=testing . ../../install.sh1011# nvm_source with no parameter returns the git endpoint12echo $(nvm_source) | grep "nvm.git$" > /dev/null || die "nvm_source without arguments should return the location of the git repo" 1314# nvm_source with git parameter returns the location of the nvm repo15echo $(nvm_source "git") | grep "nvm.git$" > /dev/null || die "nvm_source without arguments should return the location of the git repo" 1617# nvm_source with script parameter returns the location of nvm.sh18echo $(nvm_source "script") | grep "nvm.sh$" > /dev/null || die "nvm_source \"script\" should return the location of nvm.sh"1920# nvm_source with script-nvm-exec parameter returns the location of nvm-exec21echo $(nvm_source "script-nvm-exec") | grep "nvm-exec$" > /dev/null || die "nvm_source \"script-nvm-exec\" should return the location of nvm.sh"2223# nvm_source with any other parameter errors out and exits24nvm_source "anything" 2> /dev/null && die "nvm_source with invalid parameter should exit"25out=$(nvm_source "anything" 2>&1 >/dev/null) || : #Saving the process here26[ -z "$out" ] && die "nvm_source with invalid parameter should error out"2728#nvm_source should always return NVM_SOURCE no matter the parameters29NVM_SOURCE="my_location"30out=$(nvm_source)31[ "_$out" = "_my_location" ] || die "nvm_source without arguments should have returned \$NVM_SOURCE. Got \"$out\""32out=$(nvm_source "git")33[ "_$out" = "_my_location" ] || die "nvm_source git should have returned \$NVM_SOURCE. Got \"$out\""34out=$(nvm_source "script")35[ "_$out" = "_my_location" ] || die "nvm_source script should have returned \$NVM_SOURCE. Got \"$out\""36out=$(nvm_source "anything")37[ "_$out" = "_my_location" ] || die "nvm_source script should have returned \$NVM_SOURCE. Got \"$out\""3839cleanup40