Use nvm_version_path everywhere possible.
parent
986abbf5db
commit
213ff003d0
46
nvm.sh
46
nvm.sh
|
@ -197,7 +197,7 @@ nvm_ls() {
|
||||||
fi
|
fi
|
||||||
# If it looks like an explicit version, don't do anything funny
|
# If it looks like an explicit version, don't do anything funny
|
||||||
if [ `expr "$PATTERN" : "v[0-9]*\.[0-9]*\.[0-9]*$"` != 0 ]; then
|
if [ `expr "$PATTERN" : "v[0-9]*\.[0-9]*\.[0-9]*$"` != 0 ]; then
|
||||||
if [ -d "$NVM_DIR/$PATTERN" ]; then
|
if [ -d "$(nvm_version_path "$PATTERN")" ]; then
|
||||||
VERSIONS="$PATTERN"
|
VERSIONS="$PATTERN"
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
|
@ -270,7 +270,7 @@ nvm_print_versions() {
|
||||||
echo "$1" | while read VERSION; do
|
echo "$1" | while read VERSION; do
|
||||||
if [ "$VERSION" = "$NVM_CURRENT" ]; then
|
if [ "$VERSION" = "$NVM_CURRENT" ]; then
|
||||||
FORMAT='\033[0;32m-> %9s\033[0m'
|
FORMAT='\033[0;32m-> %9s\033[0m'
|
||||||
elif [ -d "$NVM_DIR/$VERSION" ]; then
|
elif [ -d "$(nvm_version_path "$VERSION")" ]; then
|
||||||
FORMAT='\033[0;34m%12s\033[0m'
|
FORMAT='\033[0;34m%12s\033[0m'
|
||||||
elif [ "$VERSION" = "system" ]; then
|
elif [ "$VERSION" = "system" ]; then
|
||||||
FORMAT='\033[0;33m%12s\033[0m'
|
FORMAT='\033[0;33m%12s\033[0m'
|
||||||
|
@ -391,7 +391,7 @@ nvm() {
|
||||||
fi
|
fi
|
||||||
provided_version="$NVM_RC_VERSION"
|
provided_version="$NVM_RC_VERSION"
|
||||||
fi
|
fi
|
||||||
[ -d "$NVM_DIR/$provided_version" ] && echo "$provided_version is already installed." >&2 && return
|
[ -d "$(nvm_version_path "$provided_version")" ] && echo "$provided_version is already installed." >&2 && return
|
||||||
|
|
||||||
VERSION=`nvm_remote_version $provided_version`
|
VERSION=`nvm_remote_version $provided_version`
|
||||||
ADDITIONAL_PARAMETERS=''
|
ADDITIONAL_PARAMETERS=''
|
||||||
|
@ -404,7 +404,7 @@ nvm() {
|
||||||
shift
|
shift
|
||||||
done
|
done
|
||||||
|
|
||||||
if [ -d "$NVM_DIR/$VERSION" ]; then
|
if [ -d "$(nvm_version_path "$VERSION")" ]; then
|
||||||
echo "$VERSION is already installed." >&2
|
echo "$VERSION is already installed." >&2
|
||||||
nvm use "$VERSION"
|
nvm use "$VERSION"
|
||||||
return $?
|
return $?
|
||||||
|
@ -433,7 +433,7 @@ nvm() {
|
||||||
nvm_checksum "$tmptarball" $sum && \
|
nvm_checksum "$tmptarball" $sum && \
|
||||||
tar -xzf "$tmptarball" -C "$tmpdir" --strip-components 1 && \
|
tar -xzf "$tmptarball" -C "$tmpdir" --strip-components 1 && \
|
||||||
rm -f "$tmptarball" && \
|
rm -f "$tmptarball" && \
|
||||||
mv "$tmpdir" "$NVM_DIR/$VERSION"
|
mv "$tmpdir" "$(nvm_version_path "$VERSION")"
|
||||||
)
|
)
|
||||||
then
|
then
|
||||||
nvm use $VERSION
|
nvm use $VERSION
|
||||||
|
@ -472,9 +472,9 @@ nvm() {
|
||||||
nvm_checksum "$tmptarball" $sum && \
|
nvm_checksum "$tmptarball" $sum && \
|
||||||
tar -xzf "$tmptarball" -C "$tmpdir" && \
|
tar -xzf "$tmptarball" -C "$tmpdir" && \
|
||||||
cd "$tmpdir/node-$VERSION" && \
|
cd "$tmpdir/node-$VERSION" && \
|
||||||
./configure --prefix="$NVM_DIR/$VERSION" $ADDITIONAL_PARAMETERS && \
|
./configure --prefix="$(nvm_version_path "$VERSION")" $ADDITIONAL_PARAMETERS && \
|
||||||
$make $MAKE_CXX && \
|
$make $MAKE_CXX && \
|
||||||
rm -f "$NVM_DIR/$VERSION" 2>/dev/null && \
|
rm -f "$(nvm_version_path "$VERSION")" 2>/dev/null && \
|
||||||
$make $MAKE_CXX install
|
$make $MAKE_CXX install
|
||||||
)
|
)
|
||||||
then
|
then
|
||||||
|
@ -506,7 +506,7 @@ nvm() {
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
VERSION=`nvm_version $PATTERN`
|
VERSION=`nvm_version $PATTERN`
|
||||||
if [ ! -d $NVM_DIR/$VERSION ]; then
|
if [ ! -d "$(nvm_version_path "$VERSION")" ]; then
|
||||||
echo "$VERSION version is not installed..." >&2
|
echo "$VERSION version is not installed..." >&2
|
||||||
return;
|
return;
|
||||||
fi
|
fi
|
||||||
|
@ -518,7 +518,7 @@ nvm() {
|
||||||
"$NVM_DIR/src/node-$VERSION.tar.gz" \
|
"$NVM_DIR/src/node-$VERSION.tar.gz" \
|
||||||
"$NVM_DIR/bin/node-${t}" \
|
"$NVM_DIR/bin/node-${t}" \
|
||||||
"$NVM_DIR/bin/node-${t}.tar.gz" \
|
"$NVM_DIR/bin/node-${t}.tar.gz" \
|
||||||
"$NVM_DIR/$VERSION" 2>/dev/null
|
"$(nvm_version_path "$VERSION")" 2>/dev/null
|
||||||
echo "Uninstalled node $VERSION"
|
echo "Uninstalled node $VERSION"
|
||||||
|
|
||||||
# Rm any aliases that point to uninstalled version.
|
# Rm any aliases that point to uninstalled version.
|
||||||
|
@ -579,32 +579,34 @@ nvm() {
|
||||||
if [ -z "$VERSION" ]; then
|
if [ -z "$VERSION" ]; then
|
||||||
VERSION=`nvm_version $2`
|
VERSION=`nvm_version $2`
|
||||||
fi
|
fi
|
||||||
if [ ! -d "$NVM_DIR/$VERSION" ]; then
|
local NVM_VERSION_DIR
|
||||||
|
NVM_VERSION_DIR="$(nvm_version_path "$VERSION")"
|
||||||
|
if [ ! -d "$NVM_VERSION_DIR" ]; then
|
||||||
echo "$VERSION version is not installed yet" >&2
|
echo "$VERSION version is not installed yet" >&2
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
# Strip other version from PATH
|
# Strip other version from PATH
|
||||||
PATH=`nvm_strip_path "$PATH" "/bin"`
|
PATH=`nvm_strip_path "$PATH" "/bin"`
|
||||||
# Prepend current version
|
# Prepend current version
|
||||||
PATH=`nvm_prepend_path "$PATH" "$NVM_DIR/$VERSION/bin"`
|
PATH=`nvm_prepend_path "$PATH" "$NVM_VERSION_DIR/bin"`
|
||||||
if [ -z "$MANPATH" ]; then
|
if [ -z "$MANPATH" ]; then
|
||||||
MANPATH=$(manpath)
|
MANPATH=$(manpath)
|
||||||
fi
|
fi
|
||||||
# Strip other version from MANPATH
|
# Strip other version from MANPATH
|
||||||
MANPATH=`nvm_strip_path "$MANPATH" "/share/man"`
|
MANPATH=`nvm_strip_path "$MANPATH" "/share/man"`
|
||||||
# Prepend current version
|
# Prepend current version
|
||||||
MANPATH=`nvm_prepend_path "$MANPATH" "$NVM_DIR/$VERSION/share/man"`
|
MANPATH=`nvm_prepend_path "$MANPATH" "$NVM_VERSION_DIR/share/man"`
|
||||||
# Strip other version from NODE_PATH
|
# Strip other version from NODE_PATH
|
||||||
NODE_PATH=`nvm_strip_path "$NODE_PATH" "/lib/node_modules"`
|
NODE_PATH=`nvm_strip_path "$NODE_PATH" "/lib/node_modules"`
|
||||||
# Prepend current version
|
# Prepend current version
|
||||||
NODE_PATH=`nvm_prepend_path "$NODE_PATH" "$NVM_DIR/$VERSION/lib/node_modules"`
|
NODE_PATH=`nvm_prepend_path "$NODE_PATH" "$NVM_VERSION_DIR/lib/node_modules"`
|
||||||
export PATH
|
export PATH
|
||||||
hash -r
|
hash -r
|
||||||
export MANPATH
|
export MANPATH
|
||||||
export NODE_PATH
|
export NODE_PATH
|
||||||
export NVM_PATH="$NVM_DIR/$VERSION/lib/node"
|
export NVM_PATH="$NVM_VERSION_DIR/lib/node"
|
||||||
export NVM_BIN="$NVM_DIR/$VERSION/bin"
|
export NVM_BIN="$NVM_VERSION_DIR/bin"
|
||||||
rm -f "$NVM_DIR/current" && ln -s "$NVM_DIR/$VERSION" "$NVM_DIR/current"
|
rm -f "$NVM_DIR/current" && ln -s "$NVM_VERSION_DIR" "$NVM_DIR/current"
|
||||||
echo "Now using node $VERSION"
|
echo "Now using node $VERSION"
|
||||||
;;
|
;;
|
||||||
"run" )
|
"run" )
|
||||||
|
@ -640,14 +642,16 @@ nvm() {
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -d "$NVM_DIR/$VERSION" ]; then
|
local NVM_VERSION_DIR
|
||||||
|
NVM_VERSION_DIR=$(nvm_version_path "$VERSION")
|
||||||
|
if [ ! -d "$NVM_VERSION_DIR" ]; then
|
||||||
echo "$VERSION version is not installed yet" >&2
|
echo "$VERSION version is not installed yet" >&2
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
RUN_NODE_PATH=`nvm_strip_path "$NODE_PATH" "/lib/node_modules"`
|
RUN_NODE_PATH=`nvm_strip_path "$NODE_PATH" "/lib/node_modules"`
|
||||||
RUN_NODE_PATH=`nvm_prepend_path "$NODE_PATH" "$NVM_DIR/$VERSION/lib/node_modules"`
|
RUN_NODE_PATH=`nvm_prepend_path "$NODE_PATH" "$NVM_VERSION_DIR/lib/node_modules"`
|
||||||
echo "Running node $VERSION"
|
echo "Running node $VERSION"
|
||||||
NODE_PATH=$RUN_NODE_PATH $NVM_DIR/$VERSION/bin/node "$@"
|
NODE_PATH=$RUN_NODE_PATH $NVM_VERSION_DIR/bin/node "$@"
|
||||||
;;
|
;;
|
||||||
"exec" )
|
"exec" )
|
||||||
shift
|
shift
|
||||||
|
@ -665,7 +669,9 @@ nvm() {
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -d "$NVM_DIR/$VERSION" ]; then
|
local NVM_VERSION_DIR
|
||||||
|
NVM_VERSION_DIR=$(nvm_version_path "$VERSION")
|
||||||
|
if [ ! -d "$NVM_VERSION_DIR" ]; then
|
||||||
echo "$VERSION version is not installed yet" >&2
|
echo "$VERSION version is not installed yet" >&2
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Reference in New Issue