Consolidate `reinstall-packages-from` logic to one place `nvm install`

master
Jordan Harband 2015-04-05 16:00:16 -07:00
parent d68f667464
commit a26ef4f1be
1 changed files with 12 additions and 19 deletions

31
nvm.sh
View File

@ -980,10 +980,8 @@ nvm_install_node_binary() {
nvm_install_node_source() { nvm_install_node_source() {
local VERSION local VERSION
VERSION="$1" VERSION="$1"
local REINSTALL_PACKAGES_FROM
REINSTALL_PACKAGES_FROM="$2"
local ADDITIONAL_PARAMETERS local ADDITIONAL_PARAMETERS
ADDITIONAL_PARAMETERS="$3" ADDITIONAL_PARAMETERS="$2"
if [ -n "$ADDITIONAL_PARAMETERS" ]; then if [ -n "$ADDITIONAL_PARAMETERS" ]; then
echo "Additional options while compiling: $ADDITIONAL_PARAMETERS" echo "Additional options while compiling: $ADDITIONAL_PARAMETERS"
@ -1029,9 +1027,6 @@ nvm_install_node_source() {
$make $MAKE_CXX install $make $MAKE_CXX install
) )
then then
if nvm use "$VERSION" && [ ! -z "$REINSTALL_PACKAGES_FROM" ] && [ "_$REINSTALL_PACKAGES_FROM" != "_N/A" ]; then
nvm reinstall-packages "$REINSTALL_PACKAGES_FROM"
fi
if ! nvm_has "npm" ; then if ! nvm_has "npm" ; then
echo "Installing npm..." echo "Installing npm..."
if nvm_version_greater 0.2.0 "$VERSION"; then if nvm_version_greater 0.2.0 "$VERSION"; then
@ -1204,31 +1199,29 @@ nvm() {
# io.js does not have a SunOS binary # io.js does not have a SunOS binary
nobinary=1 nobinary=1
fi fi
local NVM_INSTALL_SUCCESS
# skip binary install if "nobinary" option specified. # skip binary install if "nobinary" option specified.
if [ $nobinary -ne 1 ] && nvm_binary_available "$VERSION"; then if [ $nobinary -ne 1 ] && nvm_binary_available "$VERSION"; then
local NVM_INSTALL_SUCCESS
if [ "$NVM_IOJS" = true ] && nvm_install_iojs_binary "$VERSION" "$REINSTALL_PACKAGES_FROM"; then if [ "$NVM_IOJS" = true ] && nvm_install_iojs_binary "$VERSION" "$REINSTALL_PACKAGES_FROM"; then
NVM_INSTALL_SUCCESS=true NVM_INSTALL_SUCCESS=true
elif [ "$NVM_IOJS" != true ] && nvm_install_node_binary "$VERSION" "$REINSTALL_PACKAGES_FROM"; then elif [ "$NVM_IOJS" != true ] && nvm_install_node_binary "$VERSION" "$REINSTALL_PACKAGES_FROM"; then
NVM_INSTALL_SUCCESS=true NVM_INSTALL_SUCCESS=true
fi fi
elif [ "$NVM_IOJS" = true ]; then
# nvm_install_iojs_source "$VERSION" "$ADDITIONAL_PARAMETERS"
echo "Installing iojs from source is not currently supported" >&2
return 105
elif nvm_install_node_source "$VERSION" "$ADDITIONAL_PARAMETERS"; then
NVM_INSTALL_SUCCESS=true
fi
if [ "$NVM_INSTALL_SUCCESS" = true ] \ if [ "$NVM_INSTALL_SUCCESS" = true ] && nvm use "$VERSION"; then
&& nvm use "$VERSION" \ if [ ! -z "$REINSTALL_PACKAGES_FROM" ] \
&& [ ! -z "$REINSTALL_PACKAGES_FROM" ] \
&& [ "_$REINSTALL_PACKAGES_FROM" != "_N/A" ]; then && [ "_$REINSTALL_PACKAGES_FROM" != "_N/A" ]; then
nvm reinstall-packages "$REINSTALL_PACKAGES_FROM" nvm reinstall-packages "$REINSTALL_PACKAGES_FROM"
fi fi
return $?
fi
if [ "$NVM_IOJS" = true ]; then
# nvm_install_iojs_source "$VERSION" "$REINSTALL_PACKAGES_FROM" "$ADDITIONAL_PARAMETERS"
echo "Installing iojs from source is not currently supported" >&2
return 105
else
nvm_install_node_source "$VERSION" "$REINSTALL_PACKAGES_FROM" "$ADDITIONAL_PARAMETERS"
fi fi
return $?
;; ;;
"uninstall" ) "uninstall" )
if [ $# -ne 2 ]; then if [ $# -ne 2 ]; then