mirror of
				https://github.com/nvm-sh/nvm.git
				synced 2025-10-31 18:25:52 +08:00 
			
		
		
		
	Attempt to improve nvm copy-packages
				
					
				
			This commit is contained in:
		
							
								
								
									
										10
									
								
								nvm.sh
									
									
									
									
									
								
							
							
						
						
									
										10
									
								
								nvm.sh
									
									
									
									
									
								
							| @@ -726,17 +726,15 @@ nvm() { | |||||||
|         nvm help |         nvm help | ||||||
|         return 127 |         return 127 | ||||||
|       fi |       fi | ||||||
|       VERSION=`nvm_version $2` |       VERSION=$(nvm_version "$2") | ||||||
|       local ROOT |       local ROOT | ||||||
|       ROOT=`(nvm use $VERSION && npm -g root)` |       ROOT=$(nvm use $VERSION && npm -g root) | ||||||
|       local ROOTDEPTH |  | ||||||
|       ROOTDEPTH=$((`echo $ROOT | sed 's/[^\/]//g'|wc -m` -1)) |  | ||||||
|  |  | ||||||
|       # declare local INSTALLS first, otherwise it doesn't work in zsh |       # declare local INSTALLS first, otherwise it doesn't work in zsh | ||||||
|       local INSTALLS |       local INSTALLS | ||||||
|       INSTALLS=`nvm use $VERSION > /dev/null && npm -g -p ll | \grep "$ROOT\/[^/]\+$" | cut -d '/' -f $(($ROOTDEPTH + 2)) | cut -d ":" -f 2 | \grep -v npm | tr "\n" " "` |       INSTALLS=$(nvm use $VERSION > /dev/null && npm list --global --parseable --depth=0 2> /dev/null | tail -n +2 | grep -o -e '/[^/]*$' | cut -c 2- | xargs) | ||||||
|  |  | ||||||
|       npm install -g ${INSTALLS[@]} |       npm install -g --quiet $INSTALLS | ||||||
|     ;; |     ;; | ||||||
|     "clear-cache" ) |     "clear-cache" ) | ||||||
|       rm -f $NVM_DIR/v* 2>/dev/null |       rm -f $NVM_DIR/v* 2>/dev/null | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user