[Fix] Improve `nvm_is_version_installed` to check for a node executable instead of root dir
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by Joshua Li · committed by Jordan Harband · parent a5f42d9 · Browse files · 6 files·+27 added−19 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
6 files+27 added−19 removed
- tests:+26 added−18 removed
- other:+1 added−1 removed
Provenance
- Commit
0cdc184- Tree
86af1c8- Author
Joshua Li <joshua.r.li.98@gmail.com>- Committer
Jordan Harband <ljharb@gmail.com>- Parent
a5f42d9
6 files changed+27 added−19 removed
modified:test/fast/Aliases/setup+6 added-3 removed
1 #!/bin/sh2 3+\. ../../../nvm.sh4+\. ../../common.sh5+6 for i in $(seq 1 10)7 do8 echo 0.0.$i > ../../../alias/test-stable-$i6- mkdir -p ../../../v0.0.$i9+ make_fake_node v0.0.$i10 echo 0.1.$i > ../../../alias/test-unstable-$i8- mkdir -p ../../../v0.1.$i11+ make_fake_node v0.1.$i12 echo 0.2.$i > ../../../alias/test-iojs-$i10- mkdir -p ../../../versions/io.js/v0.2.$i13+ make_fake_iojs v0.2.$i14 donemodified:test/fast/Running "nvm deactivate" should unset the nvm environment variables.+5 added-4 removed
1 #!/bin/sh2 3 set -ex4 5-mkdir -p ../../v0.2.36-5 die () { echo "$@" ; exit 1; }6 9-[ `expr $PATH : ".*v0.2.3/.*/bin.*"` = 0 ] || echo "WARNING: Unexpectedly found v0.2.3 already active" >&210-7 \. ../../nvm.sh8+\. ../common.sh9 10+make_fake_node v0.2.311+12+[ `expr $PATH : ".*v0.2.3/.*/bin.*"` = 0 ] || echo "WARNING: Unexpectedly found v0.2.3 already active" >&213+14 nvm use --delete-prefix v0.2.3 || die "Failed to activate v0.2.3"15 [ `expr "$PATH" : ".*v0.2.3/.*/bin.*"` != 0 ] || die "PATH not set up properly"16 [ `expr "$NODE_PATH" : ".*v0.2.3/.*/lib/node_modules.*"` = 0 ] || die "NODE_PATH should not contain (npm root -g)"17 # ^ note: NODE_PATH should not contain `npm root -g` since globals should not be requireable6 unmodified linesmodified:test/fast/Running "nvm uninstall" should remove the appropriate directory.+5 added-5 removed
1 #!/bin/sh2 3 set -ex4 5-cd ../..6-mkdir v0.0.17-mkdir src/node-v0.0.15+\. ../../nvm.sh6+\. ../common.sh7 9-. ./nvm.sh8+make_fake_node v0.0.19+10 nvm uninstall v0.0.111 12-[ ! -d 'v0.0.1' ] && [ ! -d 'src/node-v0.0.1/files' ]12+[ ! -d 'v0.0.1' ]modified:test/fast/Running "nvm uninstall" with incorrect file permissions fails nicely+4 added-6 removed
1 #!/bin/sh2 3 set -ex4 5-cd ../..6-mkdir v0.0.17-mkdir src/node-v0.0.15+\. ../../nvm.sh6+\. ../common.sh7 9-sudo touch v0.0.1/sudo8+make_fake_node v0.0.19+sudo touch ""$(nvm_version_path v0.0.1)"/sudo"10 11-. ./nvm.sh12-11 RETURN_MESSAGE="$(nvm uninstall v0.0.1 2>&1 || echo)"12 CHECK_FOR="Cannot uninstall, incorrect permissions on installation folder"13 14 [ "${RETURN_MESSAGE#*$CHECK_FOR}" != "$RETURN_MESSAGE" ] || exit 1modified:test/installation_node/install hook+6 added
17 unmodified lines18 }19 20 ! nvm_is_version_installed "${VERSION}" || nvm uninstall "${VERSION}" || die 'uninstall failed'21 22+# an existing but empty VERSION_PATH directory should not be enough to satisfy nvm_is_version_installed23+rm -rf "${VERSION_PATH}"24+mkdir -p "${VERSION_PATH}"25+nvm_is_version_installed "${VERSION}" && die 'nvm_is_version_installed check not strict enough'26+rmdir "${VERSION_PATH}"27+28 OUTPUT="$(NVM_INSTALL_THIRD_PARTY_HOOK=succeed nvm install "${VERSION}")"29 USE_OUTPUT="$(nvm use "${VERSION}")"30 EXPECTED_OUTPUT="${VERSION} node std binary ${VERSION_PATH}31 Downloading and installing node ${VERSION}...14 unmodified linesmodified:nvm.sh+1 added-1 removed
128 unmodified lines129 [ "$(nvm deactivate >/dev/null 2>&1 && command -v iojs)" != '' ]130 }131 132 nvm_is_version_installed() {133- [ -n "${1-}" ] && [ -d "$(nvm_version_path "${1-}" 2> /dev/null)" ]133+ [ -n "${1-}" ] && [ -x "$(nvm_version_path "$1" 2> /dev/null)"/bin/node ]134 }135 136 nvm_print_npm_version() {137 if nvm_has "npm"; then3519 unmodified lines