mirror of
				https://github.com/nvm-sh/nvm.git
				synced 2025-10-31 10:15:53 +08:00 
			
		
		
		
	read version from .nvmrc if not specified
This commit is contained in:
		
							
								
								
									
										20
									
								
								nvm.sh
									
									
									
									
									
								
							
							
						
						
									
										20
									
								
								nvm.sh
									
									
									
									
									
								
							| @@ -16,6 +16,14 @@ if [ ! -z "$(which unsetopt 2>/dev/null)" ]; then | ||||
|     unsetopt nomatch 2>/dev/null | ||||
| fi | ||||
|  | ||||
| # Obtain nvm version from rc file | ||||
| function rc_nvm_version { | ||||
|   if [ -e .nvmrc ]; then | ||||
|         RC_VERSION=`cat .nvmrc | head -n 1` | ||||
|     echo "Found .nvmrc files with version <$RC_VERSION>" | ||||
|   fi | ||||
| } | ||||
|  | ||||
| # Expand a version using the version cache | ||||
| nvm_version() | ||||
| { | ||||
| @@ -348,6 +356,18 @@ nvm() | ||||
|         nvm help | ||||
|         return | ||||
|       fi | ||||
|       if [ $# -eq 1 ]; then | ||||
|         rc_nvm_version | ||||
|         if [ ! -z $RC_VERSION ]; then | ||||
|             VERSION=`nvm_version $RC_VERSION` | ||||
|         fi | ||||
|       else | ||||
|         VERSION=`nvm_version $2` | ||||
|       fi | ||||
|       if [ -z $VERSION ]; then | ||||
|         nvm help | ||||
|         return | ||||
|       fi | ||||
|       VERSION=`nvm_version $2` | ||||
|       if [ ! -d $NVM_DIR/$VERSION ]; then | ||||
|         echo "$VERSION version is not installed yet" | ||||
|   | ||||
		Reference in New Issue
	
	Block a user