Skip to content

Commit c72f2c6

Browse files
gitburdljharb
authored andcommitted
[Fix] nvm ls-remote: accept versions that end with a dot
Fixes #983.
1 parent f2c5ce4 commit c72f2c6

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

nvm.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1240,6 +1240,10 @@ nvm_ls_remote_index_tab() {
12401240
local PATTERN
12411241
PATTERN="${3-}"
12421242

1243+
if [ "${PATTERN#"${PATTERN%?}"}" = '.' ]; then
1244+
PATTERN="${PATTERN%.}"
1245+
fi
1246+
12431247
local VERSIONS
12441248
if [ -n "${PATTERN}" ] && [ "${PATTERN}" != '*' ]; then
12451249
if [ "${FLAVOR}" = 'iojs' ]; then

test/fast/Unit tests/nvm_ls_remote

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,19 @@ v0.3.8"
4040

4141
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "nvm_ls_remote 0.3 did not output 0.3.x versions; got $OUTPUT"
4242

43+
OUTPUT="$(nvm_ls_remote 0.3.)"
44+
EXPECTED_OUTPUT="v0.3.0
45+
v0.3.1
46+
v0.3.2
47+
v0.3.3
48+
v0.3.4
49+
v0.3.5
50+
v0.3.6
51+
v0.3.7
52+
v0.3.8"
53+
54+
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "nvm_ls_remote 0.3. did not output 0.3.x versions; got $OUTPUT"
55+
4356
# Sanity checks
4457
OUTPUT="$(nvm_print_implicit_alias remote stable)"
4558
EXPECTED_OUTPUT_PATH="${MOCKS_DIR}/nvm_print_implicit_alias remote stable.txt"

0 commit comments

Comments
 (0)