mirror of
				https://github.com/nvm-sh/nvm.git
				synced 2025-10-31 18:25:52 +08:00 
			
		
		
		
	fix copy-packages in zsh
fixes #299, finally, using the local var syntax
This commit is contained in:
		
							
								
								
									
										8
									
								
								nvm.sh
									
									
									
									
									
								
							
							
						
						
									
										8
									
								
								nvm.sh
									
									
									
									
									
								
							| @@ -492,9 +492,13 @@ nvm() { | ||||
|           return | ||||
|         fi | ||||
|         local VERSION=`nvm_version $2` | ||||
|         local ROOT=`nvm use $VERSION && npm -g root` | ||||
|         local ROOT=`(nvm use $VERSION && npm -g root) | tail -n1` | ||||
|         local ROOTDEPTH=$((`echo $ROOT | sed 's/[^\/]//g'|wc -m` -1)) | ||||
|         local 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" " "` ) | ||||
|  | ||||
|         # declare local INSTALLS first, otherwise it doesn't work in zsh | ||||
|         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" " "` ) | ||||
|  | ||||
|         npm install -g ${INSTALLS[@]} | ||||
|     ;; | ||||
|     "clear-cache" ) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user