Skip to content

Commit

Permalink
[Fix] nvm ls-remote: accept versions that end with a dot
Browse files Browse the repository at this point in the history
Fixes #983.
  • Loading branch information
gitburd authored and ljharb committed Sep 24, 2020
1 parent f2c5ce4 commit c72f2c6
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
4 changes: 4 additions & 0 deletions nvm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -1240,6 +1240,10 @@ nvm_ls_remote_index_tab() {
local PATTERN
PATTERN="${3-}"

if [ "${PATTERN#"${PATTERN%?}"}" = '.' ]; then
PATTERN="${PATTERN%.}"
fi

local VERSIONS
if [ -n "${PATTERN}" ] && [ "${PATTERN}" != '*' ]; then
if [ "${FLAVOR}" = 'iojs' ]; then
Expand Down
13 changes: 13 additions & 0 deletions test/fast/Unit tests/nvm_ls_remote
Original file line number Diff line number Diff line change
Expand Up @@ -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="$(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
OUTPUT="$(nvm_print_implicit_alias remote stable)"
EXPECTED_OUTPUT_PATH="${MOCKS_DIR}/nvm_print_implicit_alias remote stable.txt"
Expand Down

0 comments on commit c72f2c6

Please sign in to comment.