mirror of
				https://github.com/nvm-sh/nvm.git
				synced 2025-10-31 10:15:53 +08:00 
			
		
		
		
	Adding nvm_version_dir
				
					
				
			This commit is contained in:
		
							
								
								
									
										13
									
								
								nvm.sh
									
									
									
									
									
								
							
							
						
						
									
										13
									
								
								nvm.sh
									
									
									
									
									
								
							| @@ -95,6 +95,19 @@ nvm_rc_version() { | |||||||
|   fi |   fi | ||||||
| } | } | ||||||
|  |  | ||||||
|  | nvm_version_dir() { | ||||||
|  |   local NVM_USE_NEW_DIR | ||||||
|  |   NVM_USE_NEW_DIR="$1" | ||||||
|  |   if [ -z "$NVM_USE_NEW_DIR" ] || [ "$NVM_USE_NEW_DIR" = "new" ]; then | ||||||
|  |     echo "$NVM_DIR/versions" | ||||||
|  |   elif [ "$NVM_USE_NEW_DIR" = "old" ]; then | ||||||
|  |     echo "$NVM_DIR" | ||||||
|  |   else | ||||||
|  |     echo "unknown version dir" >&2 | ||||||
|  |     return 3 | ||||||
|  |   fi | ||||||
|  | } | ||||||
|  |  | ||||||
| nvm_version_path() { | nvm_version_path() { | ||||||
|   local VERSION |   local VERSION | ||||||
|   VERSION="$1" |   VERSION="$1" | ||||||
|   | |||||||
							
								
								
									
										11
									
								
								test/fast/Unit tests/nvm_version_dir
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										11
									
								
								test/fast/Unit tests/nvm_version_dir
									
									
									
									
									
										Executable file
									
								
							| @@ -0,0 +1,11 @@ | |||||||
|  | #!/bin/sh | ||||||
|  |  | ||||||
|  | die () { echo $@ ; exit 1; } | ||||||
|  |  | ||||||
|  | . ../../../nvm.sh | ||||||
|  |  | ||||||
|  | [ "$(nvm_version_dir)" = "$NVM_DIR/versions" ] || die '"nvm_version_dir" did not return new dir path' | ||||||
|  | [ "$(nvm_version_dir new)" = "$(nvm_version_dir)" ] || die '"nvm_version_dir new" did not return new dir path' | ||||||
|  | [ "$(nvm_version_dir old)" = "$NVM_DIR" ] || die '"nvm_version_dir old" did not return old dir path' | ||||||
|  | [ "$(nvm_version_dir foo 2>&1)" = "unknown version dir" ] || die '"nvm_version_dir foo" did not error out' | ||||||
|  |  | ||||||
		Reference in New Issue
	
	Block a user