diff --git a/nvm.sh b/nvm.sh index cc54366..c6641fd 100644 --- a/nvm.sh +++ b/nvm.sh @@ -199,6 +199,11 @@ nvm_version() { return $? fi + case "_$PATTERN" in + "_$(nvm_node_prefix)" | "_$(nvm_node_prefix)-") + PATTERN="stable" + ;; + esac VERSION="$(nvm_ls "$PATTERN" | tail -n1)" if [ -z "$VERSION" ] || [ "_$VERSION" = "_N/A" ]; then echo "N/A" diff --git a/test/fast/Unit tests/nvm_version b/test/fast/Unit tests/nvm_version index 7babb8c..4d5063b 100755 --- a/test/fast/Unit tests/nvm_version +++ b/test/fast/Unit tests/nvm_version @@ -29,8 +29,9 @@ nvm_ls() { echo "line 2" echo "pattern: $1" } - [ "_$(nvm_version foo)" = "_pattern: foo" ] || die '"nvm_version foo" did not pass the pattern to "nvm_ls", or return the last line' +[ "_$(nvm_version node)" = "_pattern: stable" ] || die '"nvm_version node" did not pass "stable" to "nvm_ls"' +[ "_$(nvm_version node-)" = "_pattern: stable" ] || die '"nvm_version node-" did not pass "stable" to "nvm_ls"' nvm_ls() { echo "N/A"; } OUTPUT="$(nvm_version foo)"