mirror of
				https://github.com/nvm-sh/nvm.git
				synced 2025-10-31 18:25:52 +08:00 
			
		
		
		
	Using an nvm_curl function instead of curl/wget directly.
				
					
				
			This commit is contained in:
		
							
								
								
									
										28
									
								
								install.sh
									
									
									
									
									
								
							
							
						
						
									
										28
									
								
								install.sh
									
									
									
									
									
								
							| @@ -11,16 +11,18 @@ if [ -z "$NVM_DIR" ]; then | |||||||
|   NVM_DIR="$HOME/.nvm" |   NVM_DIR="$HOME/.nvm" | ||||||
| fi | fi | ||||||
|  |  | ||||||
| if ! nvm_has "curl"; then | if nvm_has "curl"; then | ||||||
|   if nvm_has "wget"; then |   nvm_curl() { | ||||||
|     # Emulate curl with wget |     curl $* | ||||||
|     curl() { |   } | ||||||
|       ARGS="$* " | elif nvm_has "wget"; then | ||||||
|       ARGS=${ARGS/-s /-q } |   # Emulate curl with wget | ||||||
|       ARGS=${ARGS/-o /-O } |   nvm_curl() { | ||||||
|       wget "$ARGS" |     ARGS="$* " | ||||||
|     } |     ARGS=${ARGS/-s /-q } | ||||||
|   fi |     ARGS=${ARGS/-o /-O } | ||||||
|  |     wget "$ARGS" | ||||||
|  |   } | ||||||
| fi | fi | ||||||
|  |  | ||||||
| install_nvm_from_git() { | install_nvm_from_git() { | ||||||
| @@ -55,7 +57,7 @@ install_nvm_as_script() { | |||||||
|   else |   else | ||||||
|     echo "=> Downloading nvm as script to '$NVM_DIR'" |     echo "=> Downloading nvm as script to '$NVM_DIR'" | ||||||
|   fi |   fi | ||||||
|   curl -s "$NVM_SOURCE" -o "$NVM_DIR/nvm.sh" || { |   nvm_curl -s "$NVM_SOURCE" -o "$NVM_DIR/nvm.sh" || { | ||||||
|     echo >&2 "Failed to download '$NVM_SOURCE'.." |     echo >&2 "Failed to download '$NVM_SOURCE'.." | ||||||
|     return 1 |     return 1 | ||||||
|   } |   } | ||||||
| @@ -65,7 +67,7 @@ if [ -z "$METHOD" ]; then | |||||||
|   # Autodetect install method |   # Autodetect install method | ||||||
|   if nvm_has "git"; then |   if nvm_has "git"; then | ||||||
|     install_nvm_from_git |     install_nvm_from_git | ||||||
|   elif nvm_has "curl"; then |   elif nvm_has "nvm_curl"; then | ||||||
|     install_nvm_as_script |     install_nvm_as_script | ||||||
|   else |   else | ||||||
|     echo >&2 "You need git, curl, or wget to install nvm" |     echo >&2 "You need git, curl, or wget to install nvm" | ||||||
| @@ -80,7 +82,7 @@ else | |||||||
|     install_nvm_from_git |     install_nvm_from_git | ||||||
|   fi |   fi | ||||||
|   if [ "$METHOD" = "script" ]; then |   if [ "$METHOD" = "script" ]; then | ||||||
|     if ! nvm_has "curl"; then |     if ! nvm_has "nvm_curl"; then | ||||||
|       echo >&2 "You need curl or wget to install nvm" |       echo >&2 "You need curl or wget to install nvm" | ||||||
|       exit 1 |       exit 1 | ||||||
|     fi |     fi | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user