Skip to content

Commit

Permalink
Don't try to copy npm itself with nvm copy-packages.
Browse files Browse the repository at this point in the history
Fixes #504.
  • Loading branch information
ljharb committed Aug 22, 2014
1 parent fd9e01b commit 3a0b1b5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion nvm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -783,7 +783,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- | xargs)
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)

npm install -g --quiet $INSTALLS
;;
Expand Down
6 changes: 3 additions & 3 deletions test/slow/nvm copy-packages/should work as expected
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ 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 npm recursive-blame uglify-js yo"
EXPECTED_PACKAGES="autoprefixer bower david eslint grunt-cli grunth-cli http-server jshint marked node-gyp recursive-blame uglify-js yo"

npm install -g --quiet $EXPECTED_PACKAGES

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- | sort | uniq | xargs)
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)

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- | sort | uniq | xargs)
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" = "$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)"
Expand Down

0 comments on commit 3a0b1b5

Please sign in to comment.