summaryrefslogtreecommitdiff
path: root/ext/console/01_colors.js
diff options
context:
space:
mode:
authorBartek IwaƄczuk <biwanczuk@gmail.com>2022-01-17 23:23:49 +0100
committerGitHub <noreply@github.com>2022-01-17 23:23:49 +0100
commitbc666e42a89f2f6ab104e5f1c1298ec590a99ce9 (patch)
tree3c2873e350e73b229182fffe1102d7779cac22ac /ext/console/01_colors.js
parent1ab5dea367800defa264b633705f8b535bb167d9 (diff)
fix(ext/console): don't depend on globalThis present (#13387)
Diffstat (limited to 'ext/console/01_colors.js')
-rw-r--r--ext/console/01_colors.js14
1 files changed, 13 insertions, 1 deletions
diff --git a/ext/console/01_colors.js b/ext/console/01_colors.js
index 138eaa6d9..42551963c 100644
--- a/ext/console/01_colors.js
+++ b/ext/console/01_colors.js
@@ -11,6 +11,16 @@
ArrayPrototypeJoin,
} = window.__bootstrap.primordials;
+ let noColor = false;
+
+ function setNoColor(value) {
+ noColor = value;
+ }
+
+ function getNoColor() {
+ return noColor;
+ }
+
function code(open, close) {
return {
open: `\x1b[${open}m`,
@@ -79,7 +89,7 @@
}
function maybeColor(fn) {
- return !(globalThis.Deno?.noColor ?? false) ? fn : (s) => s;
+ return !noColor ? fn : (s) => s;
}
window.__bootstrap.colors = {
@@ -95,5 +105,7 @@
magenta,
stripColor,
maybeColor,
+ setNoColor,
+ getNoColor,
};
})(this);