mirror of
				https://github.com/nvm-sh/nvm.git
				synced 2025-10-31 10:15:53 +08:00 
			
		
		
		
	Fix nvm ls v1.0.3 so that it locates iojs-v1.0.3.
				
					
				
			Also fix `nvm uninstall v1.0.3` so it won't uninstall it if it's the current version. node versions will still take priority if there's ever a version overlap.
This commit is contained in:
		
							
								
								
									
										6
									
								
								nvm.sh
									
									
									
									
									
								
							
							
						
						
									
										6
									
								
								nvm.sh
									
									
									
									
									
								
							| @@ -469,6 +469,8 @@ nvm_ls() { | |||||||
|   if [ "_$(echo "$PATTERN" | cut -c1-1)" = "_v" ] && [ "_$(nvm_num_version_groups "$PATTERN")" = "_3" ]; then |   if [ "_$(echo "$PATTERN" | cut -c1-1)" = "_v" ] && [ "_$(nvm_num_version_groups "$PATTERN")" = "_3" ]; then | ||||||
|     if [ -d "$(nvm_version_path "$PATTERN")" ]; then |     if [ -d "$(nvm_version_path "$PATTERN")" ]; then | ||||||
|       VERSIONS="$PATTERN" |       VERSIONS="$PATTERN" | ||||||
|  |     elif [ -d "$(nvm_version_path "$(nvm_add_iojs_prefix "$PATTERN")")" ]; then | ||||||
|  |       VERSIONS="$(nvm_add_iojs_prefix "$PATTERN")" | ||||||
|     fi |     fi | ||||||
|   else |   else | ||||||
|     case "$PATTERN" in |     case "$PATTERN" in | ||||||
| @@ -1081,8 +1083,8 @@ nvm() { | |||||||
|           VERSION="$(nvm_version "$PATTERN")" |           VERSION="$(nvm_version "$PATTERN")" | ||||||
|         ;; |         ;; | ||||||
|       esac |       esac | ||||||
|       if [ "_$PATTERN" = "_$(nvm_ls_current)" ]; then |       if [ "_$VERSION" = "_$(nvm_ls_current)" ]; then | ||||||
|         if nvm_is_iojs_version "$PATTERN"; then |         if nvm_is_iojs_version "$VERSION"; then | ||||||
|           echo "nvm: Cannot uninstall currently-active io.js version, $VERSION (inferred from $PATTERN)." >&2 |           echo "nvm: Cannot uninstall currently-active io.js version, $VERSION (inferred from $PATTERN)." >&2 | ||||||
|         else |         else | ||||||
|           echo "nvm: Cannot uninstall currently-active node version, $VERSION (inferred from $PATTERN)." >&2 |           echo "nvm: Cannot uninstall currently-active node version, $VERSION (inferred from $PATTERN)." >&2 | ||||||
|   | |||||||
							
								
								
									
										14
									
								
								test/slow/nvm use/Running "nvm use v1.0.0" uses iojs-v1.0.0 iojs version
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										14
									
								
								test/slow/nvm use/Running "nvm use v1.0.0" uses iojs-v1.0.0 iojs version
									
									
									
									
									
										Executable file
									
								
							| @@ -0,0 +1,14 @@ | |||||||
|  | #!/bin/sh | ||||||
|  |  | ||||||
|  | die () { echo $@ ; exit 1; } | ||||||
|  |  | ||||||
|  | . ../../../nvm.sh | ||||||
|  |  | ||||||
|  | nvm deactivate 2>&1 >/dev/null || die 'deactivate failed' | ||||||
|  |  | ||||||
|  | nvm use 'v1.0.0' || die 'nvm use v1.0.0 failed' | ||||||
|  | OUTPUT="$(nvm current)" | ||||||
|  | EXPECTED_OUTPUT="$(nvm_version v1.0.0)" | ||||||
|  |  | ||||||
|  | [ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] \ | ||||||
|  |   || die "'nvm use v1.0.0' + 'nvm current' did not output '$EXPECTED_OUTPUT'; got '$OUTPUT'" | ||||||
		Reference in New Issue
	
	Block a user