Ensure `nvm_version node` and `nvm_version node-` report the latest stable node version.

master
Jordan Harband 2015-01-19 10:05:36 -08:00
parent 247bd310ef
commit f1f11e3b7a
2 changed files with 7 additions and 1 deletions

5
nvm.sh
View File

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

View File

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