mirror of
https://github.com/nvm-sh/nvm.git
synced 2025-09-09 09:49:05 +00:00
Preserve PATH locations order when changing versions
This commit is contained in:

committed by
Jordan Harband

parent
7b8af94fc9
commit
334897ae39
@@ -6,17 +6,17 @@ mkdir -p ../../v0.2.3
|
||||
|
||||
die () { echo "$@" ; exit 1; }
|
||||
|
||||
[ `expr $PATH : ".*v0.2.3/.*/bin"` = 0 ] || echo "WARNING: Unexpectedly found v0.2.3 already active" >&2
|
||||
[ `expr $PATH : ".*v0.2.3/.*/bin.*"` = 0 ] || echo "WARNING: Unexpectedly found v0.2.3 already active" >&2
|
||||
|
||||
\. ../../nvm.sh
|
||||
|
||||
nvm use --delete-prefix v0.2.3 || die "Failed to activate v0.2.3"
|
||||
[ `expr "$PATH" : ".*v0.2.3/.*/bin"` != 0 ] || die "PATH not set up properly"
|
||||
[ `expr "$NODE_PATH" : ".*v0.2.3/.*/lib/node_modules"` = 0 ] || die "NODE_PATH should not contain (npm root -g)"
|
||||
[ `expr "$PATH" : ".*v0.2.3/.*/bin.*"` != 0 ] || die "PATH not set up properly"
|
||||
[ `expr "$NODE_PATH" : ".*v0.2.3/.*/lib/node_modules.*"` = 0 ] || die "NODE_PATH should not contain (npm root -g)"
|
||||
# ^ note: NODE_PATH should not contain `npm root -g` since globals should not be requireable
|
||||
[ `expr "$NVM_BIN" : ".*v0.2.3/bin"` != 0 ] || die "NODE_BIN should contain bin directory path"
|
||||
|
||||
nvm deactivate || die "Failed to deactivate v0.2.3"
|
||||
[ `expr "$PATH" : ".*v0.2.3/.*/bin"` = 0 ] || die "PATH not cleaned properly"
|
||||
[ `expr "$NODE_PATH" : ".*v0.2.3/.*/lib/node_modules"` = 0 ] || die "NODE_PATH not cleaned properly"
|
||||
[ `expr "$PATH" : ".*v0.2.3/.*/bin.*"` = 0 ] || die "PATH not cleaned properly"
|
||||
[ `expr "$NODE_PATH" : ".*v0.2.3/.*/lib/node_modules.*"` = 0 ] || die "NODE_PATH not cleaned properly"
|
||||
[ "_$NVM_BIN" = "_" ] || die "NVM_BIN should be unset: got '$NVM_BIN'"
|
||||
|
Reference in New Issue
Block a user