mirror of
				https://github.com/nvm-sh/nvm.git
				synced 2025-10-31 18:25:52 +08:00 
			
		
		
		
	accerlate nvm invoke when change directory
This commit is contained in:
		| @@ -316,9 +316,16 @@ Put this into your `$HOME/.zshrc` to call `nvm use` automatically whenever you e | |||||||
| # place this after nvm initialization! | # place this after nvm initialization! | ||||||
| autoload -U add-zsh-hook | autoload -U add-zsh-hook | ||||||
| load-nvmrc() { | load-nvmrc() { | ||||||
|   if [[ -f .nvmrc && -r .nvmrc ]]; then |   local node_version="$(nvm version)" | ||||||
|     nvm use |   local nvmrc_path="$(nvm_find_nvmrc)" | ||||||
|   elif [[ $(nvm version) != $(nvm version default)  ]]; then |  | ||||||
|  |   if [ -n "$nvmrc_path" ]; then | ||||||
|  |     local nvmrc_node_version=$(nvm version "$(cat "${nvmrc_path}")") | ||||||
|  |  | ||||||
|  |     if [ "$nvmrc_node_version" != "N/A" ] && [ "$nvmrc_node_version" != "$node_version" ]; then | ||||||
|  |       nvm use  | ||||||
|  |     fi | ||||||
|  |   elif [ "$node_version" != "$(nvm version default)" ]; then | ||||||
|     echo "Reverting to nvm default version" |     echo "Reverting to nvm default version" | ||||||
|     nvm use default |     nvm use default | ||||||
|   fi |   fi | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user