mirror of
				https://github.com/nvm-sh/nvm.git
				synced 2025-11-04 06:57:12 +00:00 
			
		
		
		
	Fix shell startup time
makes nvm a function that gets replaced by the real nvm function. After that, it will get called with the specified arguments. Calls after this initialization call, will use the original nvm shell function. By introducing this indirection, shell startup time is significantly improved.
This commit is contained in:
		
							parent
							
								
									ecba036cbf
								
							
						
					
					
						commit
						404467aceb
					
				@ -287,7 +287,13 @@ nvm_do_install() {
 | 
			
		||||
  local INSTALL_DIR
 | 
			
		||||
  INSTALL_DIR="$(nvm_install_dir)"
 | 
			
		||||
 | 
			
		||||
  SOURCE_STR="\nexport NVM_DIR=\"$INSTALL_DIR\"\n[ -s \"\$NVM_DIR/nvm.sh\" ] && . \"\$NVM_DIR/nvm.sh\"  # This loads nvm\n"
 | 
			
		||||
  SOURCE_STR="\nexport NVM_DIR=\"$INSTALL_DIR\""
 | 
			
		||||
  SOURCE_STR="$SOURCE_STR\nnvm() {\n  echo Loading nvm for first use in this shell >/dev/stderr"
 | 
			
		||||
  SOURCE_STR="$SOURCE_STR\n  [ -s \"\$NVM_DIR/nvm.sh\" ] && . \"$NVM_DIR/nvm.sh\" # This loads nvm"
 | 
			
		||||
  SOURCE_STR="$SOURCE_STR\n  nvm \"\$@\"\n}"
 | 
			
		||||
  echo $SOURCE_STR
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
  if [ -z "${NVM_PROFILE-}" ] ; then
 | 
			
		||||
    echo "=> Profile not found. Tried ${NVM_PROFILE} (as defined in \$PROFILE), ~/.bashrc, ~/.bash_profile, ~/.zshrc, and ~/.profile."
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user