|
1 | 1 | #!/bin/sh
|
2 | 2 |
|
3 |
| -set -ex |
4 |
| - |
5 |
| -cleanup () { |
6 |
| - unset -f die cleanup |
7 |
| - unset NVM_SOURCE out |
8 |
| -} |
9 |
| -die () { echo "$@" ; cleanup ; exit 1; } |
| 3 | +die () { echo "$@" ; exit 1; } |
10 | 4 |
|
11 | 5 | NVM_ENV=testing \. ../../install.sh
|
12 | 6 |
|
13 |
| -# nvm_source with no parameter returns the git endpoint |
14 |
| -echo $(nvm_source) | grep "https://github.com/nvm-sh/nvm.git$" > /dev/null || die "nvm_source without arguments should return the location of the git repo" |
15 |
| -[ "$(nvm_source)" = "https://github.com/nvm-sh/nvm.git" ] || die "nvm_source without arguments should return the location of the git repo" |
16 |
| -NVM_GITHUB_REPO="other-user/other-nvm" echo $(nvm_source) | grep "https://github.com/other-user/other-nvm.git$" > /dev/null || die "nvm_source without arguments should return the location of the git repo" |
17 |
| - |
18 |
| -# nvm_source with git parameter returns the location of the nvm repo |
19 |
| -echo $(nvm_source "git") | grep "https://github.com/nvm-sh/nvm.git$" > /dev/null || die "nvm_source without arguments should return the location of the git repo" |
20 |
| -NVM_GITHUB_REPO="other-user/other-nvm" echo $(nvm_source "git") | grep "https://github.com/other-user/other-nvm.git$" > /dev/null || die "nvm_source without arguments should return the location of the git repo" |
21 |
| - |
22 |
| -# nvm_source with script parameter returns the location of nvm.sh |
23 |
| -echo $(nvm_source "script") | grep "https://raw.githubusercontent.com/nvm-sh/nvm/$(nvm_latest_version)/nvm.sh$" > /dev/null || die "nvm_source \"script\" should return the location of nvm.sh" |
24 |
| -NVM_GITHUB_REPO="other-user/other-nvm" NVM_INSTALL_VERSION="v0.37.2" echo $(nvm_source "script") | grep "https://raw.githubusercontent.com/other-user/other-nvm/v0.37.2/nvm.sh$" > /dev/null || die "nvm_source \"script\" should return the location of nvm.sh" |
25 |
| - |
26 |
| -# nvm_source with script-nvm-exec parameter returns the location of nvm-exec |
27 |
| -echo $(nvm_source "script-nvm-exec") | grep "https://raw.githubusercontent.com/nvm-sh/nvm/$(nvm_latest_version)/nvm-exec$" > /dev/null || die "nvm_source \"script-nvm-exec\" should return the location of nvm.sh" |
28 |
| -NVM_GITHUB_REPO="other-user/other-nvm" NVM_INSTALL_VERSION="v0.37.2" echo $(nvm_source "script-nvm-exec") | grep "https://raw.githubusercontent.com/other-user/other-nvm/v0.37.2/nvm-exec$" > /dev/null || die "nvm_source \"script-nvm-exec\" should return the location of nvm.sh" |
29 |
| - |
30 |
| -# nvm_source with any other parameter errors out and exits |
31 |
| -nvm_source "anything" 2> /dev/null && die "nvm_source with invalid parameter should exit" |
32 |
| -out=$(nvm_source "anything" 2>&1 >/dev/null) || : #Saving the process here |
33 |
| -[ -z "$out" ] && die "nvm_source with invalid parameter should error out" |
34 |
| - |
35 |
| -#nvm_source should always return NVM_SOURCE no matter the parameters |
36 |
| -NVM_SOURCE="my_location" |
37 |
| -out=$(nvm_source) |
38 |
| -[ "_$out" = "_my_location" ] || die "nvm_source without arguments should have returned \$NVM_SOURCE. Got \"$out\"" |
39 |
| -out=$(nvm_source "git") |
40 |
| -[ "_$out" = "_my_location" ] || die "nvm_source git should have returned \$NVM_SOURCE. Got \"$out\"" |
41 |
| -out=$(nvm_source "script") |
42 |
| -[ "_$out" = "_my_location" ] || die "nvm_source script should have returned \$NVM_SOURCE. Got \"$out\"" |
43 |
| -out=$(nvm_source "anything") |
44 |
| -[ "_$out" = "_my_location" ] || die "nvm_source script should have returned \$NVM_SOURCE. Got \"$out\"" |
| 7 | +#nvm_do_install is available |
| 8 | +type nvm_do_install > /dev/null 2>&1 || die 'nvm_do_install is not available' |
45 | 9 |
|
46 |
| -cleanup |
| 10 | +die 'I want to fail !!!' |
0 commit comments