mirror of
				https://github.com/nvm-sh/nvm.git
				synced 2025-10-31 10:15:53 +08:00 
			
		
		
		
	Make nvm copy-packages refuse to copy packages from the currently activated version.
				
					
				
			This commit is contained in:
		
							
								
								
									
										12
									
								
								nvm.sh
									
									
									
									
									
								
							
							
						
						
									
										12
									
								
								nvm.sh
									
									
									
									
									
								
							| @@ -792,9 +792,17 @@ nvm() { | ||||
|         nvm help | ||||
|         return 127 | ||||
|       fi | ||||
|       VERSION="$(nvm_version "$2")" | ||||
|  | ||||
|       # declare local INSTALLS first, otherwise it doesn't work in zsh | ||||
|       local PROVIDED_VERSION | ||||
|       PROVIDED_VERSION="$2" | ||||
|  | ||||
|       if [ "$PROVIDED_VERSION" = "$(nvm_ls_current)" ]; then | ||||
|         echo 'Can not copy packages from the current version of node.' >&2 | ||||
|         return 2 | ||||
|       fi | ||||
|  | ||||
|       local VERSION | ||||
|       VERSION="$(nvm_version "$PROVIDED_VERSION")" | ||||
|       local INSTALLS | ||||
|       INSTALLS=$(nvm use "$VERSION" > /dev/null && npm list -g --depth=0 | tail -n +2 | \grep -o -e ' [^@]*' | cut -c 2- | \grep -v npm | xargs) | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user