mirror of
				https://github.com/nvm-sh/nvm.git
				synced 2025-10-31 10:15:53 +08:00 
			
		
		
		
	npm ls has a bug in some versions when "--parseable --depth=0" is used together.
				
					
				
			This commit is contained in:
		
							
								
								
									
										2
									
								
								nvm.sh
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								nvm.sh
									
									
									
									
									
								
							| @@ -789,7 +789,7 @@ nvm() { | |||||||
|  |  | ||||||
|       # 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 list --global --parseable --depth=0 2> /dev/null | tail -n +2 | \grep -o -e '/[^/]*$' | cut -c 2- | \grep -v npm | xargs) |       INSTALLS=$(nvm use "$VERSION" > /dev/null && npm list -g --depth=0 | tail -n +2 | \grep -o -e ' [^@]*' | cut -c 2- | \grep -v npm | xargs) | ||||||
|  |  | ||||||
|       echo "$INSTALLS" | xargs npm install -g --quiet |       echo "$INSTALLS" | xargs npm install -g --quiet | ||||||
|     ;; |     ;; | ||||||
|   | |||||||
| @@ -11,10 +11,10 @@ EXPECTED_PACKAGES="autoprefixer bower david eslint grunt-cli grunth-cli http-ser | |||||||
| echo "$EXPECTED_PACKAGES" | xargs npm install -g --quiet | echo "$EXPECTED_PACKAGES" | xargs npm install -g --quiet | ||||||
|  |  | ||||||
| nvm use 0.10.29 | nvm use 0.10.29 | ||||||
| ORIGINAL_PACKAGES=$(npm list --global --parseable --depth=0 2> /dev/null | tail -n +2 | \grep -o -e '/[^/]*$' | cut -c 2- | \grep -v npm | sort | uniq | xargs) | ORIGINAL_PACKAGES=$(npm list -g --depth=0 | tail -n +2 | \grep -o -e ' [^@]*' | cut -c 2- | \grep -v npm | sort | uniq | xargs) | ||||||
|  |  | ||||||
| nvm copy-packages 0.10.28 | nvm copy-packages 0.10.28 | ||||||
| FINAL_PACKAGES=$(npm list --global --parseable --depth=0 2> /dev/null | tail -n +2 | \grep -o -e '/[^/]*$' | cut -c 2- | \grep -v npm | sort | uniq | xargs) | FINAL_PACKAGES=$(npm list -g --depth=0 | tail -n +2 | \grep -o -e ' [^@]*' | cut -c 2- | \grep -v npm | sort | uniq | xargs) | ||||||
|  |  | ||||||
| [ "$FINAL_PACKAGES" = "$EXPECTED_PACKAGES" ] || die "final packages ($FINAL_PACKAGES) did not match expected packages ($EXPECTED_PACKAGES)" | [ "$FINAL_PACKAGES" = "$EXPECTED_PACKAGES" ] || die "final packages ($FINAL_PACKAGES) did not match expected packages ($EXPECTED_PACKAGES)" | ||||||
| [ "$ORIGINAL_PACKAGES" != "$FINAL_PACKAGES" ] || die "original packages matched final packages ($ORIGINAL_PACKAGES)" | [ "$ORIGINAL_PACKAGES" != "$FINAL_PACKAGES" ] || die "original packages matched final packages ($ORIGINAL_PACKAGES)" | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user