[Fix] `nvm ls-remote`: accept versions that end with a dot

Fixes #983.
Dena Burd 2020-09-24 13:46:29 -07:00 committed by Jordan Harband
parent f2c5ce459a
commit c72f2c6f21
No known key found for this signature in database
GPG Key ID: 9F6A681E35EF8B56
2 changed files with 17 additions and 0 deletions

4
nvm.sh
View File

@ -1240,6 +1240,10 @@ nvm_ls_remote_index_tab() {
local PATTERN local PATTERN
PATTERN="${3-}" PATTERN="${3-}"
if [ "${PATTERN#"${PATTERN%?}"}" = '.' ]; then
PATTERN="${PATTERN%.}"
fi
local VERSIONS local VERSIONS
if [ -n "${PATTERN}" ] && [ "${PATTERN}" != '*' ]; then if [ -n "${PATTERN}" ] && [ "${PATTERN}" != '*' ]; then
if [ "${FLAVOR}" = 'iojs' ]; then if [ "${FLAVOR}" = 'iojs' ]; then

View File

@ -40,6 +40,19 @@ v0.3.8"
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "nvm_ls_remote 0.3 did not output 0.3.x versions; got $OUTPUT" [ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "nvm_ls_remote 0.3 did not output 0.3.x versions; got $OUTPUT"
OUTPUT="$(nvm_ls_remote 0.3.)"
EXPECTED_OUTPUT="v0.3.0
v0.3.1
v0.3.2
v0.3.3
v0.3.4
v0.3.5
v0.3.6
v0.3.7
v0.3.8"
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "nvm_ls_remote 0.3. did not output 0.3.x versions; got $OUTPUT"
# Sanity checks # Sanity checks
OUTPUT="$(nvm_print_implicit_alias remote stable)" OUTPUT="$(nvm_print_implicit_alias remote stable)"
EXPECTED_OUTPUT_PATH="${MOCKS_DIR}/nvm_print_implicit_alias remote stable.txt" EXPECTED_OUTPUT_PATH="${MOCKS_DIR}/nvm_print_implicit_alias remote stable.txt"