`nvm reinstall-packages` should install the same version it had before.

Jordan Harband 2015-06-29 00:04:59 -07:00
parent fb2f1ac627
commit 7bce6c6c68
4 changed files with 16 additions and 11 deletions

8
nvm.sh
View File

@ -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
for LINK in "$LINKS"; do
if [ -n "$LINK" ]; then
(cd "$LINK" && npm link)
fi
done
;;
"clear-cache" )

View File

@ -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"

View File

@ -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"

View File

@ -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