mirror of
				https://github.com/nvm-sh/nvm.git
				synced 2025-10-31 18:25:52 +08:00 
			
		
		
		
	Fix NVM_DIR discovery
This commit is contained in:
		
							
								
								
									
										13
									
								
								nvm.sh
									
									
									
									
									
								
							
							
						
						
									
										13
									
								
								nvm.sh
									
									
									
									
									
								
							| @@ -5,6 +5,8 @@ | |||||||
| # Implemented by Tim Caswell <tim@creationix.com> | # Implemented by Tim Caswell <tim@creationix.com> | ||||||
| # with much bash help from Matthew Ranney | # with much bash help from Matthew Ranney | ||||||
|  |  | ||||||
|  | SCRIPT_SOURCE="$_" | ||||||
|  |  | ||||||
| nvm_has() { | nvm_has() { | ||||||
|   type "$1" > /dev/null 2>&1 |   type "$1" > /dev/null 2>&1 | ||||||
|   return $? |   return $? | ||||||
| @@ -17,14 +19,15 @@ if nvm_has "unsetopt"; then | |||||||
|   NVM_CD_FLAGS="-q" |   NVM_CD_FLAGS="-q" | ||||||
| fi | fi | ||||||
|  |  | ||||||
| # Auto detect the NVM_DIR | # Auto detect the NVM_DIR when not set | ||||||
| if [ ! -d "$NVM_DIR" ]; then | if [ -z "$NVM_DIR" ]; then | ||||||
|   if [ -n "$BASH_SOURCE" ]; then |   if [ -n "$BASH_SOURCE" ]; then | ||||||
|     export NVM_DIR=$(cd $NVM_CD_FLAGS $(dirname ${BASH_SOURCE[0]:-$0}) > /dev/null && pwd) |     SCRIPT_SOURCE="${BASH_SOURCE[0]}" | ||||||
|   else |  | ||||||
|     export NVM_DIR=$HOME/.nvm |  | ||||||
|   fi |   fi | ||||||
|  |   export NVM_DIR=$(cd $NVM_CD_FLAGS $(dirname "${SCRIPT_SOURCE:-$0}") > /dev/null && pwd) | ||||||
| fi | fi | ||||||
|  | unset SCRIPT_SOURCE 2> /dev/null | ||||||
|  |  | ||||||
|  |  | ||||||
| # Setup mirror location if not already set | # Setup mirror location if not already set | ||||||
| if [ -z "$NVM_NODEJS_ORG_MIRROR" ]; then | if [ -z "$NVM_NODEJS_ORG_MIRROR" ]; then | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user