Store the version path in a local variable for reuse.
parent
bf794ff8da
commit
4b5885d69d
19
nvm.sh
19
nvm.sh
|
@ -655,7 +655,9 @@ nvm() {
|
||||||
return 5
|
return 5
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -d "$(nvm_version_path "$VERSION")" ]; then
|
local VERSION_PATH
|
||||||
|
VERSION_PATH="$(nvm_version_path "$VERSION")"
|
||||||
|
if [ -d "$VERSION_PATH" ]; then
|
||||||
echo "$VERSION is already installed." >&2
|
echo "$VERSION is already installed." >&2
|
||||||
if nvm use "$VERSION" && [ ! -z "$REINSTALL_PACKAGES_FROM" ] && [ "_$REINSTALL_PACKAGES_FROM" != "_N/A" ]; then
|
if nvm use "$VERSION" && [ ! -z "$REINSTALL_PACKAGES_FROM" ] && [ "_$REINSTALL_PACKAGES_FROM" != "_N/A" ]; then
|
||||||
nvm reinstall-packages "$REINSTALL_PACKAGES_FROM"
|
nvm reinstall-packages "$REINSTALL_PACKAGES_FROM"
|
||||||
|
@ -686,7 +688,7 @@ nvm() {
|
||||||
nvm_checksum "$tmptarball" $sum && \
|
nvm_checksum "$tmptarball" $sum && \
|
||||||
command tar -xzf "$tmptarball" -C "$tmpdir" --strip-components 1 && \
|
command tar -xzf "$tmptarball" -C "$tmpdir" --strip-components 1 && \
|
||||||
command rm -f "$tmptarball" && \
|
command rm -f "$tmptarball" && \
|
||||||
command mv "$tmpdir" "$(nvm_version_path "$VERSION")"
|
command mv "$tmpdir" "$VERSION_PATH"
|
||||||
)
|
)
|
||||||
then
|
then
|
||||||
if nvm use "$VERSION" && [ ! -z "$REINSTALL_PACKAGES_FROM" ] && [ "_$REINSTALL_PACKAGES_FROM" != "_N/A" ]; then
|
if nvm use "$VERSION" && [ ! -z "$REINSTALL_PACKAGES_FROM" ] && [ "_$REINSTALL_PACKAGES_FROM" != "_N/A" ]; then
|
||||||
|
@ -729,9 +731,9 @@ nvm() {
|
||||||
nvm_checksum "$tmptarball" $sum && \
|
nvm_checksum "$tmptarball" $sum && \
|
||||||
command tar -xzf "$tmptarball" -C "$tmpdir" && \
|
command tar -xzf "$tmptarball" -C "$tmpdir" && \
|
||||||
cd "$tmpdir/node-$VERSION" && \
|
cd "$tmpdir/node-$VERSION" && \
|
||||||
./configure --prefix="$(nvm_version_path "$VERSION")" $ADDITIONAL_PARAMETERS && \
|
./configure --prefix="$VERSION_PATH" $ADDITIONAL_PARAMETERS && \
|
||||||
$make $MAKE_CXX && \
|
$make $MAKE_CXX && \
|
||||||
command rm -f "$(nvm_version_path "$VERSION")" 2>/dev/null && \
|
command rm -f "$VERSION_PATH" 2>/dev/null && \
|
||||||
$make $MAKE_CXX install
|
$make $MAKE_CXX install
|
||||||
)
|
)
|
||||||
then
|
then
|
||||||
|
@ -766,8 +768,11 @@ nvm() {
|
||||||
echo "nvm: Cannot uninstall currently-active node version, $PATTERN." >&2
|
echo "nvm: Cannot uninstall currently-active node version, $PATTERN." >&2
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
VERSION=`nvm_version $PATTERN`
|
local VERSION
|
||||||
if [ ! -d "$(nvm_version_path "$VERSION")" ]; then
|
VERSION="$(nvm_version "$PATTERN")"
|
||||||
|
local VERSION_PATH
|
||||||
|
VERSION_PATH="$(nvm_version_path "$VERSION")"
|
||||||
|
if [ ! -d "$VERSION_PATH" ]; then
|
||||||
echo "$VERSION version is not installed..." >&2
|
echo "$VERSION version is not installed..." >&2
|
||||||
return;
|
return;
|
||||||
fi
|
fi
|
||||||
|
@ -779,7 +784,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_version_path "$VERSION")" 2>/dev/null
|
"$VERSION_PATH" 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.
|
||||||
|
|
Loading…
Reference in New Issue