mirror of
				https://github.com/nvm-sh/nvm.git
				synced 2025-10-31 01:45:50 +08:00 
			
		
		
		
	If nvm is deactivated, display "none" or "system" instead of the system node version
This commit is contained in:
		
							
								
								
									
										10
									
								
								nvm.sh
									
									
									
									
									
								
							
							
						
						
									
										10
									
								
								nvm.sh
									
									
									
									
									
								
							| @@ -160,7 +160,15 @@ nvm_binary_available() { | |||||||
| } | } | ||||||
|  |  | ||||||
| nvm_ls_current() { | nvm_ls_current() { | ||||||
|   echo `node -v 2>/dev/null` |   local NODE_PATH | ||||||
|  |   NODE_PATH="$(which node)" | ||||||
|  |   if [ $? -ne 0 ]; then | ||||||
|  |     echo 'none' | ||||||
|  |   elif nvm_tree_contains_path "$NVM_DIR" "$NODE_PATH"; then | ||||||
|  |     echo `node -v 2>/dev/null` | ||||||
|  |   else | ||||||
|  |     echo 'system' | ||||||
|  |   fi | ||||||
| } | } | ||||||
|  |  | ||||||
| nvm_ls() { | nvm_ls() { | ||||||
|   | |||||||
| @@ -3,4 +3,8 @@ | |||||||
| die () { echo $@ ; exit 1; } | die () { echo $@ ; exit 1; } | ||||||
|  |  | ||||||
| . ../../nvm.sh | . ../../nvm.sh | ||||||
| [ "$(nvm current)" = "$(node -v)" ] || die "Failed to find current version" |  | ||||||
|  | nvm deactivate 2>&1 | ||||||
|  |  | ||||||
|  | [ "$(nvm current)" = "system" ] || [ "$(nvm current)" = "none" ] || die '"nvm current" did not report "system" or "none" when deactivated' | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user