mirror of
https://github.com/nvm-sh/nvm.git
synced 2025-10-30 00:45:49 +08:00
[Fix] reinstall-packages: Prevent install/link when no packages found
Fixes #1744.
This commit is contained in:
committed by
Jordan Harband
parent
25b7f264d5
commit
d6fa67166c
@@ -3,6 +3,8 @@
|
||||
\. ../../../nvm.sh
|
||||
nvm install 0.10.28
|
||||
nvm install 0.10.29
|
||||
nvm install 4.7.1
|
||||
nvm install 4.7.2
|
||||
|
||||
if [ -f ".nvmrc" ]; then
|
||||
mv .nvmrc .nvmrc.bak
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
\. ../../../nvm.sh
|
||||
nvm uninstall v0.10.28
|
||||
nvm uninstall v0.10.29
|
||||
nvm uninstall v4.7.1
|
||||
nvm uninstall v4.7.2
|
||||
|
||||
rm -f .nvmrc
|
||||
|
||||
|
||||
18
test/slow/nvm reinstall-packages/works with no installs
Executable file
18
test/slow/nvm reinstall-packages/works with no installs
Executable file
@@ -0,0 +1,18 @@
|
||||
#!/bin/sh
|
||||
|
||||
die () { echo "$@" ; exit 1; }
|
||||
|
||||
\. ../../../nvm.sh
|
||||
|
||||
get_packages() {
|
||||
npm list -g --depth=0 | \sed -e '1 d' -e 's/^.* \(.*\)@.*/\1/' -e '/^npm$/ d' | xargs
|
||||
}
|
||||
|
||||
nvm use 4.7.2
|
||||
ORIGINAL_PACKAGES=$(get_packages)
|
||||
|
||||
nvm reinstall-packages 4.7.1
|
||||
FINAL_PACKAGES=$(get_packages)
|
||||
|
||||
[ -z "${ORIGINAL_PACKAGES}" ] || die "original packages were not empty: ${ORIGINAL_PACKAGES}"
|
||||
[ -z "${FINAL_PACKAGES}" ] || die "final packages were not empty: ${FINAL_PACKAGES}"
|
||||
Reference in New Issue
Block a user