@@ -1888,79 +1888,79 @@ nvm_print_versions() {
1888
1888
-v installed_color=" $INSTALLED_COLOR " -v system_color=" $SYSTEM_COLOR " \
1889
1889
-v current_color=" $CURRENT_COLOR " -v default_color=" $DEFAULT_COLOR " \
1890
1890
-v old_lts_color=" $DEFAULT_COLOR " -v has_colors=" $NVM_HAS_COLORS " '
1891
- function alen(arr, i, len) { len=0; for(i in arr) len++; return len; }
1892
- function v2a(v, a) { sub(/^(iojs-)?v/, "", v); split(v, a, "."); }
1893
- function v2m(v, a) { sub(/^(iojs-)?v/, "", v); split(v, a, "."); return a[1]; }
1894
- function vcmp(v1,v2,a1,a2,i,d) { v2a(v1,a1); v2a(v2,a2); for(i=1;i<4;i++) { d = a1[i] - a2[i]; if(d!=0) return d; } return 0; }
1895
- BEGIN {
1896
- fmt_installed = has_colors ? (installed_color ? "\033[" installed_color "%15s\033[0m" : "%15s") : "%15s *";
1897
- fmt_system = has_colors ? (system_color ? "\033[" system_color "%15s\033[0m" : "%15s") : "%15s *";
1898
- fmt_current = has_colors ? (current_color ? "\033[" current_color "->%13s\033[0m" : "%15s") : "->%13s *";
1899
-
1900
- latest_lts_color = current_color;
1901
- sub(/0;/, "1;", latest_lts_color);
1902
-
1903
- fmt_latest_lts = has_colors && latest_lts_color ? ("\033[" latest_lts_color " (Latest LTS: %s)\033[0m") : " (Latest LTS: %s)";
1904
- fmt_old_lts = has_colors && old_lts_color ? ("\033[" old_lts_color " (LTS: %s)\033[0m") : " (LTS: %s)";
1905
-
1906
- split(remote_versions, lines, "|");
1907
- split(installed_versions, installed, "|");
1908
- rows = alen(lines);
1909
- filter_on = (vcmp("v0.0.0", min) != 0);
1910
- current_major = -1;
1911
- for (m = n = 1; n <= rows; n++) {
1912
- split(lines[n], fields, "[[:blank:]]+");
1913
- cols = alen(fields);
1914
- version = fields[1];
1915
- is_installed = 0;
1916
- for (i in installed) {
1917
- if (version == installed[i]) {
1918
- is_installed = 1;
1919
- break;
1891
+ function alen(arr, i, len) { len=0; for(i in arr) len++; return len; }
1892
+ function v2a(v, a) { sub(/^(iojs-)?v/, "", v); split(v, a, "."); }
1893
+ function v2m(v, a) { sub(/^(iojs-)?v/, "", v); split(v, a, "."); return a[1]; }
1894
+ function vcmp(v1,v2,a1,a2,i,d) { v2a(v1,a1); v2a(v2,a2); for(i=1;i<4;i++) { d = a1[i] - a2[i]; if(d!=0) return d; } return 0; }
1895
+ BEGIN {
1896
+ fmt_installed = has_colors ? (installed_color ? "\033[" installed_color "%15s\033[0m" : "%15s") : "%15s *";
1897
+ fmt_system = has_colors ? (system_color ? "\033[" system_color "%15s\033[0m" : "%15s") : "%15s *";
1898
+ fmt_current = has_colors ? (current_color ? "\033[" current_color "->%13s\033[0m" : "%15s") : "->%13s *";
1899
+
1900
+ latest_lts_color = current_color;
1901
+ sub(/0;/, "1;", latest_lts_color);
1902
+
1903
+ fmt_latest_lts = has_colors && latest_lts_color ? ("\033[" latest_lts_color " (Latest LTS: %s)\033[0m") : " (Latest LTS: %s)";
1904
+ fmt_old_lts = has_colors && old_lts_color ? ("\033[" old_lts_color " (LTS: %s)\033[0m") : " (LTS: %s)";
1905
+
1906
+ split(remote_versions, lines, "|");
1907
+ split(installed_versions, installed, "|");
1908
+ rows = alen(lines);
1909
+ filter_on = (vcmp("v0.0.0", min) != 0);
1910
+ current_major = -1;
1911
+ for (m = n = 1; n <= rows; n++) {
1912
+ split(lines[n], fields, "[[:blank:]]+");
1913
+ cols = alen(fields);
1914
+ version = fields[1];
1915
+ is_installed = 0;
1916
+ for (i in installed) {
1917
+ if (version == installed[i]) {
1918
+ is_installed = 1;
1919
+ break;
1920
+ }
1920
1921
}
1921
- }
1922
1922
1923
- if (filter_on != 0) {
1924
- if (is_installed) {
1925
- current_major = v2m(version);
1926
- } else if (vcmp(version, min) >= 0) {
1927
- filter_on = 0;
1928
- } else if (v2m(version) != current_major) {
1929
- continue;
1923
+ if (filter_on != 0) {
1924
+ if (is_installed) {
1925
+ current_major = v2m(version);
1926
+ } else if (vcmp(version, min) >= 0) {
1927
+ filter_on = 0;
1928
+ } else if (v2m(version) != current_major) {
1929
+ continue;
1930
+ }
1930
1931
}
1931
- }
1932
1932
1933
- fmt_version = "%15s";
1934
- if (version == current) {
1935
- fmt_version = fmt_current;
1936
- } else if (version == "system") {
1937
- fmt_version = fmt_system;
1938
- } else if (is_installed) {
1939
- fmt_version = fmt_installed;
1940
- }
1933
+ fmt_version = "%15s";
1934
+ if (version == current) {
1935
+ fmt_version = fmt_current;
1936
+ } else if (version == "system") {
1937
+ fmt_version = fmt_system;
1938
+ } else if (is_installed) {
1939
+ fmt_version = fmt_installed;
1940
+ }
1941
1941
1942
- padding = (is_installed && !has_colors) ? "" : " ";
1943
- if (cols == 1) {
1944
- formatted = sprintf(fmt_version, version);
1945
- } else if (cols == 2) {
1946
- formatted = sprintf((fmt_version padding fmt_old_lts), version, fields[2]);
1947
- } else if (cols == 3 && fields[3] == "*") {
1948
- formatted = sprintf((fmt_version padding fmt_latest_lts), version, fields[2]);
1949
- }
1942
+ padding = (is_installed && !has_colors) ? "" : " ";
1943
+ if (cols == 1) {
1944
+ formatted = sprintf(fmt_version, version);
1945
+ } else if (cols == 2) {
1946
+ formatted = sprintf((fmt_version padding fmt_old_lts), version, fields[2]);
1947
+ } else if (cols == 3 && fields[3] == "*") {
1948
+ formatted = sprintf((fmt_version padding fmt_latest_lts), version, fields[2]);
1949
+ }
1950
1950
1951
- output[m++] = formatted;
1952
- }
1951
+ output[m++] = formatted;
1952
+ }
1953
1953
1954
- for (n = 1; n < m; n++) {
1955
- print output[n]
1956
- }
1954
+ for (n = 1; n < m; n++) {
1955
+ print output[n]
1956
+ }
1957
1957
1958
- if (rows > --m) {
1959
- printf("[INFO] showing %d (of %d) versions.\n", m, rows) > "/dev/stderr"
1960
- }
1958
+ if (rows > --m) {
1959
+ printf("[INFO] showing %d (of %d) versions.\n", m, rows) > "/dev/stderr"
1960
+ }
1961
1961
1962
- exit
1963
- }'
1962
+ exit
1963
+ }'
1964
1964
}
1965
1965
1966
1966
nvm_validate_implicit_alias () {
0 commit comments