mirror of
https://github.com/nvm-sh/nvm.git
synced 2025-10-29 16:35:51 +08:00
Support --install option upon sourcing.
This commit is contained in:
20
test/sourcing/Sourcing nvm.sh with --install and .nvmrc should install it
Executable file
20
test/sourcing/Sourcing nvm.sh with --install and .nvmrc should install it
Executable file
@@ -0,0 +1,20 @@
|
||||
#!/bin/sh
|
||||
|
||||
die () { echo $@ ; exit 1; }
|
||||
|
||||
echo '0.10.2' > ../../.nvmrc || die 'creation of .nvmrc failed'
|
||||
|
||||
. ../../nvm.sh --install
|
||||
EXIT_CODE="$(echo $?)"
|
||||
|
||||
echo 'sourcing complete.'
|
||||
|
||||
nvm_version 0.10.2 >/dev/null 2>&1 || die "v0.10.2 not installed: $(nvm ls)"
|
||||
|
||||
[ "_$(nvm_rc_version | \grep -o -e 'with version .*$')" = "_with version <0.10.2>" ] || die "nvm_rc_version $(nvm_rc_version)"
|
||||
|
||||
[ "_$EXIT_CODE" = "_0" ] || die "sourcing returned nonzero exit code: $EXIT_CODE"
|
||||
|
||||
NVM_LS_CURRENT="$(nvm ls current | \grep -o v0.10.2)"
|
||||
[ "_$NVM_LS_CURRENT" = '_v0.10.2' ] || die "'nvm ls current' did not return '-> v0.10.2', got '$NVM_LS_CURRENT' `nvm ls`"
|
||||
|
||||
24
test/sourcing/Sourcing nvm.sh with --install should install the default
Executable file
24
test/sourcing/Sourcing nvm.sh with --install should install the default
Executable file
@@ -0,0 +1,24 @@
|
||||
#!/bin/sh
|
||||
|
||||
die () { echo $@ ; exit 1; }
|
||||
|
||||
echo '0.10.2' > ../../alias/default || die 'creation of default alias failed'
|
||||
|
||||
echo 'sourcing nvm with --install...'
|
||||
|
||||
. ../../nvm.sh --install
|
||||
EXIT_CODE="$(echo $?)"
|
||||
|
||||
echo 'sourcing complete.'
|
||||
|
||||
nvm_version 0.10.2 >/dev/null 2>&1 || die "v0.10.2 not installed: $(nvm ls)"
|
||||
|
||||
[ "_$EXIT_CODE" = "_0" ] || die "sourcing returned nonzero exit code: $EXIT_CODE"
|
||||
|
||||
NVM_LS_CURRENT="$(nvm ls current | \grep -o v0.10.2)"
|
||||
[ "_$NVM_LS_CURRENT" = '_v0.10.2' ] || die "'nvm ls current' did not return '-> v0.10.2', got '$NVM_LS_CURRENT'"
|
||||
|
||||
NVM_ALIAS_DEFAULT="$(nvm alias default)"
|
||||
[ "_$NVM_ALIAS_DEFAULT" = "_default -> 0.10.2 (-> v0.10.2)" ] \
|
||||
|| die "'nvm alias default did not return 'default -> 0.10.2 (-> v0.10.2)', got '$NVM_ALIAS_DEFAULT'"
|
||||
|
||||
Reference in New Issue
Block a user