mirror of
				https://github.com/nvm-sh/nvm.git
				synced 2025-11-04 06:57:12 +00:00 
			
		
		
		
	ensure nvm.sh really exist at the directory determined
This commit is contained in:
		
							parent
							
								
									af276b80fe
								
							
						
					
					
						commit
						d4f6c201cb
					
				
							
								
								
									
										18
									
								
								nvm-exec
									
									
									
									
									
								
							
							
						
						
									
										18
									
								
								nvm-exec
									
									
									
									
									
								
							@ -1,7 +1,15 @@
 | 
			
		||||
#!/usr/bin/env bash
 | 
			
		||||
 | 
			
		||||
function nvm_fail() {
 | 
			
		||||
  echo "$1" >&2
 | 
			
		||||
  exit 127
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
has_realpath=""
 | 
			
		||||
 | 
			
		||||
function find_nvm_dir() {
 | 
			
		||||
  if which realpath >& /dev/null; then
 | 
			
		||||
    has_realpath=yes
 | 
			
		||||
    dirname "$(realpath "$0")"
 | 
			
		||||
  else
 | 
			
		||||
    command cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd
 | 
			
		||||
@ -10,6 +18,16 @@ function find_nvm_dir() {
 | 
			
		||||
 | 
			
		||||
DIR="$(find_nvm_dir)"
 | 
			
		||||
 | 
			
		||||
function check_nvm_sh() {
 | 
			
		||||
  if [ ! -f "$DIR/nvm.sh" ]; then
 | 
			
		||||
    local rp_msg=""
 | 
			
		||||
    [ "$has_realpath" == "yes" ] || rp_msg="; missing realpath command for finding nvm-exec's realpath to search for nvm.sh"
 | 
			
		||||
    nvm_fail "Unable to find nvm.sh at $DIR$rp_msg"
 | 
			
		||||
  fi
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
check_nvm_sh
 | 
			
		||||
 | 
			
		||||
# shellcheck disable=SC1090
 | 
			
		||||
\. "$DIR/nvm.sh" --no-use
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user