From bf7bd3e793adfac2069f2f4bc5225765d347fa25 Mon Sep 17 00:00:00 2001 From: HE Shi-Jun Date: Wed, 11 Mar 2015 18:12:01 +0800 Subject: [PATCH 1/2] Only filter the package npm, not any package name contains 'npm' --- nvm.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nvm.sh b/nvm.sh index 471e220..a3ddf5a 100755 --- a/nvm.sh +++ b/nvm.sh @@ -1658,11 +1658,11 @@ $NVM_LS_REMOTE_IOJS_OUTPUT" | command grep -v "N/A" | sed '/^$/d')" echo 'No system version of node or io.js detected.' >&2 return 3 fi - INSTALLS=$(nvm deactivate > /dev/null && npm list -g --depth=0 | command tail -n +2 | command grep -o -e ' [^@]*' | command cut -c 2- | command grep -v npm | command xargs) + INSTALLS=$(nvm deactivate > /dev/null && npm list -g --depth=0 | command tail -n +2 | command grep -o -e ' [^@]*' | command cut -c 2- | command grep -vx npm | command xargs) else local VERSION VERSION="$(nvm_version "$PROVIDED_VERSION")" - INSTALLS=$(nvm use "$VERSION" > /dev/null && npm list -g --depth=0 | command tail -n +2 | command grep -o -e ' [^@]*' | command cut -c 2- | command grep -v npm | command xargs) + INSTALLS=$(nvm use "$VERSION" > /dev/null && npm list -g --depth=0 | command tail -n +2 | command grep -o -e ' [^@]*' | command cut -c 2- | command grep -vx npm | command xargs) fi echo "Copying global packages from $VERSION..." From 14b23bfa95451dcad365b180544f1082c1f6fa51 Mon Sep 17 00:00:00 2001 From: HE Shi-Jun Date: Sun, 15 Mar 2015 06:08:14 +0800 Subject: [PATCH 2/2] fix reinstall-packages test --- .../nvm reinstall-packages/should work as expected | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/test/slow/nvm reinstall-packages/should work as expected b/test/slow/nvm reinstall-packages/should work as expected index 4942e6e..7f39197 100755 --- a/test/slow/nvm reinstall-packages/should work as expected +++ b/test/slow/nvm reinstall-packages/should work as expected @@ -6,16 +6,19 @@ die () { echo "$@" ; exit 1; } nvm use 0.10.28 -EXPECTED_PACKAGES="autoprefixer bower david eslint grunt-cli grunth-cli http-server jshint marked node-gyp recursive-blame uglify-js yo" +EXPECTED_PACKAGES="autoprefixer bower david eslint grunt-cli grunth-cli http-server jshint marked node-gyp npmlist recursive-blame uglify-js yo" echo "$EXPECTED_PACKAGES" | xargs npm install -g --quiet +get_packages() { + npm list -g --depth=0 | \sed -e '1 d' -e 's/^.* \(.*\)@.*/\1/' -e '/^npm$/ d' | xargs +} + nvm use 0.10.29 -ORIGINAL_PACKAGES=$(npm list -g --depth=0 | tail -n +2 | \grep -o -e ' [^@]*' | cut -c 2- | \grep -v npm | sort | uniq | xargs) +ORIGINAL_PACKAGES=$(get_packages) nvm reinstall-packages 0.10.28 -FINAL_PACKAGES=$(npm list -g --depth=0 | tail -n +2 | \grep -o -e ' [^@]*' | cut -c 2- | \grep -v npm | sort | uniq | xargs) +FINAL_PACKAGES=$(get_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)" -