Skip to content

Commit

Permalink
do not skip installed versions
Browse files Browse the repository at this point in the history
  • Loading branch information
ryenus committed Jan 29, 2024
1 parent 28444c5 commit a81e16a
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions nvm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -1740,7 +1740,7 @@ nvm_print_versions() {
-v old_lts_color="$DEFAULT_COLOR" -v has_colors="$NVM_HAS_COLORS" '
function alen(arr, i, len) { len=0; for(i in arr) len++; return len; }
function v2a(v, a, s) { s=v; sub(/^(iojs-)?v/, "", s); split(s, a, "."); }
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; }
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; }
BEGIN {
fmt_installed = has_colors ? (installed_color ? "\033[" installed_color "%15s\033[0m" : "%15s") : "%15s *";
fmt_system = has_colors ? (system_color ? "\033[" system_color "%15s\033[0m" : "%15s") : "%15s *";
Expand All @@ -1755,14 +1755,12 @@ BEGIN {
split(remote_versions, lines, "|");
split(installed_versions, installed, "|");
rows = alen(lines);
filter = (min_ver != "v0");
filter_on = (min_ver != "v0");
for (m = n = 1; n <= rows; n++) {
split(lines[n], fields, "[[:blank:]]+");
cols = alen(fields);
version = fields[1];
if (filter && comp(version, min_ver) < 0) continue;
filter = 0;
is_installed = 0;
for (i in installed) {
if (version == installed[i]) {
Expand All @@ -1771,6 +1769,14 @@ BEGIN {
}
}
if (filter_on && !is_installed) {
if (vcmp(version, min_ver) >= 0) {
filter_on = 0;
} else {
continue;
}
}
fmt_version = "%15s";
if (version == current) {
fmt_version = fmt_current;
Expand Down

0 comments on commit a81e16a

Please sign in to comment.