From 7bce6c6c687420c54fd314157cff305b7adb98b5 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Mon, 29 Jun 2015 00:04:59 -0700 Subject: [PATCH] `nvm reinstall-packages` should install the same version it had before. --- nvm.sh | 10 ++++++---- .../io.js/install while reinstalling packages | 6 +++--- .../node/install while reinstalling packages | 6 +++--- .../nvm reinstall-packages/should work as expected | 5 ++++- 4 files changed, 16 insertions(+), 11 deletions(-) diff --git a/nvm.sh b/nvm.sh index f4481d7..c69690e 100755 --- a/nvm.sh +++ b/nvm.sh @@ -1742,17 +1742,19 @@ $NVM_LS_REMOTE_IOJS_OUTPUT" | command grep -v "N/A" | sed '/^$/d')" fi local INSTALLS - INSTALLS=$(echo "$NPMLIST" | command sed -e '/ -> / d' -e '/\(empty\)/ d' -e 's/^.* \(.*\)@.*/\1/' -e '/^npm$/ d' | command xargs) + INSTALLS=$(echo "$NPMLIST" | command sed -e '/ -> / d' -e '/\(empty\)/ d' -e 's/^.* \(.*@[^ ]*\).*/\1/' -e '/^npm@[^ ]*.*$/ d' | command xargs) echo "Reinstalling global packages from $VERSION..." echo "$INSTALLS" | command xargs npm install -g --quiet local LINKS - LINKS=$(echo "$NPMLIST" | command sed -n 's/.* -> \(.*\)/\1/ p') + LINKS="$(echo "$NPMLIST" | command sed -n 's/.* -> \(.*\)/\1/ p')" # | command sed -e '/^ *$/d;s/.*/"&"/') echo "Linking global packages from $VERSION..." - for LINK in $LINKS; do - (cd "$LINK" && npm link) + for LINK in "$LINKS"; do + if [ -n "$LINK" ]; then + (cd "$LINK" && npm link) + fi done ;; "clear-cache" ) diff --git a/test/installation/io.js/install while reinstalling packages b/test/installation/io.js/install while reinstalling packages index d7d4ee4..ebbb64a 100755 --- a/test/installation/io.js/install while reinstalling packages +++ b/test/installation/io.js/install while reinstalling packages @@ -16,8 +16,8 @@ nvm install iojs-v1.0.0 node --version | grep v1.0.0 > /dev/null || die "nvm install didn't use iojs-v1.0.0" -npm install -g is-nan@1.0.1 || die "npm install -g is-nan failed" -npm list --global | grep is-nan > /dev/null || die "is-nan isn't installed" +npm install -g object-is@0.0.0 || die "npm install -g object-is failed" +npm list --global | grep object-is > /dev/null || die "object-is isn't installed" nvm ls iojs-1 | grep iojs-v1.0.0 > /dev/null || die "nvm ls iojs-1 didn't show iojs-v1.0.0" @@ -28,5 +28,5 @@ nvm install iojs-v1.0.1 --reinstall-packages-from=iojs-1.0.0 || die "nvm install nvm use iojs-1 node --version | grep v1.0.1 > /dev/null || die "nvm use iojs-1 didn't use v1.0.1" -npm list --global | grep is-nan > /dev/null || die "is-nan isn't installed" +npm list --global | grep object-is > /dev/null || die "object-is isn't installed" diff --git a/test/installation/node/install while reinstalling packages b/test/installation/node/install while reinstalling packages index 9298212..c170a10 100755 --- a/test/installation/node/install while reinstalling packages +++ b/test/installation/node/install while reinstalling packages @@ -18,8 +18,8 @@ nvm use 0.9.7 node --version | grep v0.9.7 > /dev/null || die "nvm use 0.9.7 failed" -npm install -g is-nan@1.0.1 || die "npm install -g is-nan failed" -npm list --global | grep is-nan > /dev/null || die "is-nan isn't installed" +npm install -g object-is@0.0.0 || die "npm install -g object-is failed" +npm list --global | grep object-is > /dev/null || die "object-is isn't installed" nvm ls 0.9 | grep v0.9.7 > /dev/null || die "nvm ls 0.9 didn't show v0.9.7" @@ -30,5 +30,5 @@ nvm install 0.9.12 --reinstall-packages-from=0.9 || die "nvm install 0.9.12 --re nvm use 0.9 node --version | grep v0.9.12 > /dev/null || die "nvm ls 0.9 didn't use v0.9.12" -npm list --global | grep is-nan > /dev/null || die "is-nan isn't installed" +npm list --global | grep object-is > /dev/null || die "object-is isn't installed" diff --git a/test/slow/nvm reinstall-packages/should work as expected b/test/slow/nvm reinstall-packages/should work as expected index 506d5f4..e0156d4 100755 --- a/test/slow/nvm reinstall-packages/should work as expected +++ b/test/slow/nvm reinstall-packages/should work as expected @@ -4,12 +4,15 @@ die () { echo "$@" ; exit 1; } . ../../../nvm.sh +nvm exec 0.10.28 npm install -g npm@~1.4.11 # this is required because before 1.4.10, npm ls doesn't indicated linked packages +nvm exec 0.10.29 npm install -g npm@~1.4.11 # this is required because before 1.4.10, npm ls doesn't indicated linked packages + nvm use 0.10.28 (cd test-npmlink && npm link) EXPECTED_PACKAGES="autoprefixer bower david eslint grunt-cli grunth-cli http-server jshint marked node-gyp npmlist recursive-blame spawn-sync test-npmlink uglify-js yo" -echo "$EXPECTED_PACKAGES" | xargs npm install -g --quiet +echo "$EXPECTED_PACKAGES" | sed -e 's/test-npmlink //' | xargs npm install -g --quiet get_packages() { npm list -g --depth=0 | \sed -e '1 d' -e 's/^.* \(.*\)@.*/\1/' -e '/^npm$/ d' | xargs