Skip to content

Commit a81e16a

Browse files
committed
do not skip installed versions
1 parent 28444c5 commit a81e16a

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

nvm.sh

+10-4
Original file line numberDiff line numberDiff line change
@@ -1740,7 +1740,7 @@ nvm_print_versions() {
17401740
-v old_lts_color="$DEFAULT_COLOR" -v has_colors="$NVM_HAS_COLORS" '
17411741
function alen(arr, i, len) { len=0; for(i in arr) len++; return len; }
17421742
function v2a(v, a, s) { s=v; sub(/^(iojs-)?v/, "", s); split(s, a, "."); }
1743-
function comp(v1,v2,d,a1,a2,i) { v2a(v1,a1); v2a(v2,a2); for(i in a1) d[i] = a1[i] - a2[i]; for(i in d) { if(d[i] != 0) return d[i]}; return 0; }
1743+
function vcmp(v1,v2,a1,a2,i,d) { v2a(v1,a1); v2a(v2,a2); for(i in a1) { d = a1[i] - a2[i]; if (d != 0) return d; } return 0; }
17441744
BEGIN {
17451745
fmt_installed = has_colors ? (installed_color ? "\033[" installed_color "%15s\033[0m" : "%15s") : "%15s *";
17461746
fmt_system = has_colors ? (system_color ? "\033[" system_color "%15s\033[0m" : "%15s") : "%15s *";
@@ -1755,14 +1755,12 @@ BEGIN {
17551755
split(remote_versions, lines, "|");
17561756
split(installed_versions, installed, "|");
17571757
rows = alen(lines);
1758-
filter = (min_ver != "v0");
1758+
filter_on = (min_ver != "v0");
17591759
for (m = n = 1; n <= rows; n++) {
17601760
split(lines[n], fields, "[[:blank:]]+");
17611761
cols = alen(fields);
17621762
version = fields[1];
1763-
if (filter && comp(version, min_ver) < 0) continue;
17641763
1765-
filter = 0;
17661764
is_installed = 0;
17671765
for (i in installed) {
17681766
if (version == installed[i]) {
@@ -1771,6 +1769,14 @@ BEGIN {
17711769
}
17721770
}
17731771
1772+
if (filter_on && !is_installed) {
1773+
if (vcmp(version, min_ver) >= 0) {
1774+
filter_on = 0;
1775+
} else {
1776+
continue;
1777+
}
1778+
}
1779+
17741780
fmt_version = "%15s";
17751781
if (version == current) {
17761782
fmt_version = fmt_current;

0 commit comments

Comments
 (0)