mirror of
https://github.com/nvm-sh/nvm.git
synced 2025-09-08 07:38:17 +00:00
Respect previously nvm-loaded node version when sourcing
This commit is contained in:

committed by
Jordan Harband

parent
b111436fde
commit
eabd7ab13d
20
test/sourcing/Sourcing nvm.sh should keep version if one is active
Executable file
20
test/sourcing/Sourcing nvm.sh should keep version if one is active
Executable file
@@ -0,0 +1,20 @@
|
||||
#!/bin/sh
|
||||
|
||||
die () { echo "$@" ; exit 1; }
|
||||
|
||||
echo '0.10.1' > ../../alias/default || die "couldn't create default alias"
|
||||
|
||||
\. ../../nvm.sh || die 'sourcing returned nonzero exit code'
|
||||
|
||||
NVM_TARGET=0.10.3
|
||||
NVM_DEFAULT="$(nvm_resolve_local_alias default)"
|
||||
|
||||
[ "_$NVM_DEFAULT" != "_$NVM_TARGET" ] || die "default $NVM_DEFAULT is the same as target $NVM_TARGET"
|
||||
|
||||
nvm use $NVM_TARGET || die "nvm use $NVM_TARGET failed"
|
||||
|
||||
\. ../../nvm.sh || die 'sourcing returned nonzero exit code'
|
||||
|
||||
NVM_CURRENT="$(nvm current)"
|
||||
|
||||
[ "_${NVM_CURRENT#v}" = "_$NVM_TARGET" ] || die "node version not retained after sourcing"
|
Reference in New Issue
Block a user