HEX
Server: Apache/2.4.41
System: Linux mainweb 5.4.0-182-generic #202-Ubuntu SMP Fri Apr 26 12:29:36 UTC 2024 x86_64
User: nationalmedicaregrp (1119)
PHP: 8.3.7
Disabled: exec,passthru,shell_exec,system,popen,proc_open,pcntl_exec
Upload Files
File: /home/ubuntu/.nvm/test/sourcing/Sourcing nvm.sh should keep version if one is active
#!/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"