Support the NO_COLOR env variable in the REPL

This commit is contained in:
Saúl Ibarra Corretgé 2024-09-27 09:24:14 +02:00
parent 348d60985d
commit d0df61d04a
2 changed files with 11 additions and 2 deletions

Binary file not shown.

View file

@ -1577,7 +1577,9 @@ import * as bjson from "bjson";
} }
function print_eval_error(error) { function print_eval_error(error) {
if (show_colors) {
std.puts(colors[styles.error]); std.puts(colors[styles.error]);
}
if (error instanceof Error) { if (error instanceof Error) {
std.puts(error); std.puts(error);
std.puts('\n'); std.puts('\n');
@ -1589,7 +1591,10 @@ import * as bjson from "bjson";
std.puts(error); std.puts(error);
std.puts('\n'); std.puts('\n');
} }
if (show_colors) {
std.puts(colors.none); std.puts(colors.none);
}
handle_cmd_end(); handle_cmd_end();
} }
@ -1873,6 +1878,10 @@ import * as bjson from "bjson";
styles = themes.light; styles = themes.light;
} }
} }
s = std.getenv("NO_COLOR"); // https://no-color.org/
if (s && +s[0] !== 0) {
show_colors = false;
}
} }
load_config(); load_config();