commit
7f3a794d89
45
nvm.sh
45
nvm.sh
|
@ -97,6 +97,10 @@ nvm_format_version() {
|
||||||
echo "$1" | sed -e 's/^\([0-9]\)/v\1/g'
|
echo "$1" | sed -e 's/^\([0-9]\)/v\1/g'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
nvm_strip_path() {
|
||||||
|
echo "$1" | sed -E "s#$NVM_DIR/[^/]*$2[^:]*:?##g"
|
||||||
|
}
|
||||||
|
|
||||||
nvm_binary_available() {
|
nvm_binary_available() {
|
||||||
# binaries started with node 0.8.6
|
# binaries started with node 0.8.6
|
||||||
local MINIMAL="0.8.6"
|
local MINIMAL="0.8.6"
|
||||||
|
@ -428,20 +432,20 @@ nvm() {
|
||||||
;;
|
;;
|
||||||
"deactivate" )
|
"deactivate" )
|
||||||
if [ `expr "$PATH" : ".*$NVM_DIR/.*/bin.*"` != 0 ] ; then
|
if [ `expr "$PATH" : ".*$NVM_DIR/.*/bin.*"` != 0 ] ; then
|
||||||
export PATH=${PATH%$NVM_DIR/*/bin*}${PATH#*$NVM_DIR/*/bin:}
|
export PATH=`nvm_strip_path "$PATH" "/bin"`
|
||||||
hash -r
|
hash -r
|
||||||
echo "$NVM_DIR/*/bin removed from \$PATH"
|
echo "$NVM_DIR/*/bin removed from \$PATH"
|
||||||
else
|
else
|
||||||
echo "Could not find $NVM_DIR/*/bin in \$PATH"
|
echo "Could not find $NVM_DIR/*/bin in \$PATH"
|
||||||
fi
|
fi
|
||||||
if [ `expr "$MANPATH" : ".*$NVM_DIR/.*/share/man.*"` != 0 ] ; then
|
if [ `expr "$MANPATH" : ".*$NVM_DIR/.*/share/man.*"` != 0 ] ; then
|
||||||
export MANPATH=${MANPATH%$NVM_DIR/*/share/man*}${MANPATH#*$NVM_DIR/*/share/man:}
|
export MANPATH=`nvm_strip_path "$MANPATH" "/share/man"`
|
||||||
echo "$NVM_DIR/*/share/man removed from \$MANPATH"
|
echo "$NVM_DIR/*/share/man removed from \$MANPATH"
|
||||||
else
|
else
|
||||||
echo "Could not find $NVM_DIR/*/share/man in \$MANPATH"
|
echo "Could not find $NVM_DIR/*/share/man in \$MANPATH"
|
||||||
fi
|
fi
|
||||||
if [ `expr "$NODE_PATH" : ".*$NVM_DIR/.*/lib/node_modules.*"` != 0 ] ; then
|
if [ `expr "$NODE_PATH" : ".*$NVM_DIR/.*/lib/node_modules.*"` != 0 ] ; then
|
||||||
export NODE_PATH=${NODE_PATH%$NVM_DIR/*/lib/node_modules*}${NODE_PATH#*$NVM_DIR/*/lib/node_modules:}
|
export NODE_PATH=`nvm_strip_path "$NODE_PATH" "/lib/node_modules"`
|
||||||
echo "$NVM_DIR/*/lib/node_modules removed from \$NODE_PATH"
|
echo "$NVM_DIR/*/lib/node_modules removed from \$NODE_PATH"
|
||||||
else
|
else
|
||||||
echo "Could not find $NVM_DIR/*/lib/node_modules in \$NODE_PATH"
|
echo "Could not find $NVM_DIR/*/lib/node_modules in \$NODE_PATH"
|
||||||
|
@ -471,25 +475,21 @@ nvm() {
|
||||||
echo "$VERSION version is not installed yet"
|
echo "$VERSION version is not installed yet"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
if [ `expr "$PATH" : ".*$NVM_DIR/.*/bin"` != 0 ]; then
|
# Strip other version from PATH
|
||||||
PATH=${PATH%$NVM_DIR/*/bin*}$NVM_DIR/$VERSION/bin${PATH#*$NVM_DIR/*/bin}
|
PATH=`nvm_strip_path "$PATH" "/bin"`
|
||||||
else
|
# Prepend current version
|
||||||
PATH="$NVM_DIR/$VERSION/bin:$PATH"
|
PATH="$NVM_DIR/$VERSION/bin:$PATH"
|
||||||
fi
|
|
||||||
if [ -z "$MANPATH" ]; then
|
if [ -z "$MANPATH" ]; then
|
||||||
MANPATH=$(manpath)
|
MANPATH=$(manpath)
|
||||||
fi
|
fi
|
||||||
MANPATH=${MANPATH#*$NVM_DIR/*/man:}
|
# Strip other version from MANPATH
|
||||||
if [ `expr "$MANPATH" : ".*$NVM_DIR/.*/share/man"` != 0 ]; then
|
MANPATH=`nvm_strip_path "$MANPATH" "/share/man"`
|
||||||
MANPATH=${MANPATH%$NVM_DIR/*/share/man*}$NVM_DIR/$VERSION/share/man${MANPATH#*$NVM_DIR/*/share/man}
|
# Prepend current version
|
||||||
else
|
MANPATH="$NVM_DIR/$VERSION/share/man:$MANPATH"
|
||||||
MANPATH="$NVM_DIR/$VERSION/share/man:$MANPATH"
|
# Strip other version from NODE_PATH
|
||||||
fi
|
NODE_PATH=`nvm_strip_path "$NODE_PATH" "/lib/node_modules"`
|
||||||
if [ `expr "$NODE_PATH" : ".*$NVM_DIR/.*/lib/node_modules.*"` != 0 ]; then
|
# Prepend current version
|
||||||
NODE_PATH=${NODE_PATH%$NVM_DIR/*/lib/node_modules*}$NVM_DIR/$VERSION/lib/node_modules${NODE_PATH#*$NVM_DIR/*/lib/node_modules}
|
NODE_PATH="$NVM_DIR/$VERSION/lib/node_modules:$NODE_PATH"
|
||||||
else
|
|
||||||
NODE_PATH="$NVM_DIR/$VERSION/lib/node_modules:$NODE_PATH"
|
|
||||||
fi
|
|
||||||
export PATH
|
export PATH
|
||||||
hash -r
|
hash -r
|
||||||
export MANPATH
|
export MANPATH
|
||||||
|
@ -534,11 +534,8 @@ nvm() {
|
||||||
echo "$VERSION version is not installed yet"
|
echo "$VERSION version is not installed yet"
|
||||||
return;
|
return;
|
||||||
fi
|
fi
|
||||||
if [ `expr "$NODE_PATH" : ".*$NVM_DIR/.*/lib/node_modules.*"` != 0 ]; then
|
RUN_NODE_PATH=`nvm_strip_path "$NODE_PATH" "/lib/node_modules"`
|
||||||
RUN_NODE_PATH=${NODE_PATH%$NVM_DIR/*/lib/node_modules*}$NVM_DIR/$VERSION/lib/node_modules${NODE_PATH#*$NVM_DIR/*/lib/node_modules}
|
RUN_NODE_PATH="$NVM_DIR/$VERSION/lib/node_modules:$NODE_PATH"
|
||||||
else
|
|
||||||
RUN_NODE_PATH="$NVM_DIR/$VERSION/lib/node_modules:$NODE_PATH"
|
|
||||||
fi
|
|
||||||
echo "Running node $VERSION"
|
echo "Running node $VERSION"
|
||||||
NODE_PATH=$RUN_NODE_PATH $NVM_DIR/$VERSION/bin/node "$@"
|
NODE_PATH=$RUN_NODE_PATH $NVM_DIR/$VERSION/bin/node "$@"
|
||||||
;;
|
;;
|
||||||
|
|
|
@ -8,7 +8,7 @@ die () { echo $@ ; exit 1; }
|
||||||
|
|
||||||
. ../../nvm.sh
|
. ../../nvm.sh
|
||||||
nvm use v0.2.3 &&
|
nvm use v0.2.3 &&
|
||||||
[ `expr $PATH : ".*v0.2.3/.*/bin"` != 0 ] || die "Failed to activate v0.2.3"
|
[ `expr $PATH : ".*v0.2.3/.*/bin"` != 0 ] && [ `expr $NODE_PATH : ".*v0.2.3/.*/lib/node_modules"` != 0 ] || die "Failed to activate v0.2.3"
|
||||||
|
|
||||||
nvm deactivate &&
|
nvm deactivate &&
|
||||||
[ `expr $PATH : ".*v0.2.3/.*/bin"` = 0 ] || die "Failed to deactivate v0.2.3"
|
[ `expr $PATH : ".*v0.2.3/.*/bin"` = 0 ] && [ `expr $NODE_PATH : ".*v0.2.3/.*/lib/node_modules"` = 0 ] || die "Failed to deactivate v0.2.3"
|
||||||
|
|
Loading…
Reference in New Issue