`npm ls` has a bug in some versions when "--parseable --depth=0" is used together.

master
Jordan Harband 2014-09-02 15:04:35 -07:00
parent 603253b0cb
commit 214ce8853b
2 changed files with 3 additions and 3 deletions

2
nvm.sh
View File

@ -789,7 +789,7 @@ nvm() {
# declare local INSTALLS first, otherwise it doesn't work in zsh
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
;;

View File

@ -11,10 +11,10 @@ EXPECTED_PACKAGES="autoprefixer bower david eslint grunt-cli grunth-cli http-ser
echo "$EXPECTED_PACKAGES" | xargs npm install -g --quiet
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
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)"
[ "$ORIGINAL_PACKAGES" != "$FINAL_PACKAGES" ] || die "original packages matched final packages ($ORIGINAL_PACKAGES)"