mirror of
				https://github.com/nvm-sh/nvm.git
				synced 2025-10-31 10:15:53 +08:00 
			
		
		
		
	[Fix] install should not exit after successful git clone
Fixes #1146 by grouping the commands that handle the error. I also removed a subshell wrapper from a similar set of lines right above. It looks to me like that is no longer necessary.
This commit is contained in:
		
							
								
								
									
										13
									
								
								install.sh
									
									
									
									
									
								
							
							
						
						
									
										13
									
								
								install.sh
									
									
									
									
									
								
							| @@ -69,16 +69,19 @@ install_nvm_from_git() { | |||||||
|   if [ -d "$INSTALL_DIR/.git" ]; then |   if [ -d "$INSTALL_DIR/.git" ]; then | ||||||
|     echo "=> nvm is already installed in $INSTALL_DIR, trying to update using git" |     echo "=> nvm is already installed in $INSTALL_DIR, trying to update using git" | ||||||
|     printf "\r=> " |     printf "\r=> " | ||||||
|     (command git --git-dir="$INSTALL_DIR"/.git --work-tree="$INSTALL_DIR" fetch 2> /dev/null || { |     command git --git-dir="$INSTALL_DIR"/.git --work-tree="$INSTALL_DIR" fetch 2> /dev/null || { | ||||||
|       echo >&2 "Failed to update nvm, run 'git fetch' in $INSTALL_DIR yourself." && exit 1 |       echo >&2 "Failed to update nvm, run 'git fetch' in $INSTALL_DIR yourself." | ||||||
|     }) |       exit 1 | ||||||
|  |     } | ||||||
|   else |   else | ||||||
|     # Cloning to $NVM_DIR |     # Cloning to $NVM_DIR | ||||||
|     echo "=> Downloading nvm from git to '$INSTALL_DIR'" |     echo "=> Downloading nvm from git to '$INSTALL_DIR'" | ||||||
|     printf "\r=> " |     printf "\r=> " | ||||||
|     mkdir -p "$INSTALL_DIR" |     mkdir -p "$INSTALL_DIR" | ||||||
|     command git clone "$(nvm_source)" "$INSTALL_DIR" \ |     command git clone "$(nvm_source)" "$INSTALL_DIR" || { | ||||||
|       || echo >&2 "Failed to clone nvm repo. Please report this!" && exit 1 |       echo >&2 "Failed to clone nvm repo. Please report this!" | ||||||
|  |       exit 1 | ||||||
|  |     } | ||||||
|   fi |   fi | ||||||
|   command git --git-dir="$INSTALL_DIR"/.git --work-tree="$INSTALL_DIR" checkout --quiet "$(nvm_latest_version)" |   command git --git-dir="$INSTALL_DIR"/.git --work-tree="$INSTALL_DIR" checkout --quiet "$(nvm_latest_version)" | ||||||
|   if [ ! -z "$(command git --git-dir="$INSTALL_DIR"/.git --work-tree="$INSTALL_DIR" show-ref refs/heads/master)" ]; then |   if [ ! -z "$(command git --git-dir="$INSTALL_DIR"/.git --work-tree="$INSTALL_DIR" show-ref refs/heads/master)" ]; then | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user