mirror of
https://github.com/denoland/deno.git
synced 2024-12-25 00:29:09 -05:00
support NO_COLOR in colors module (denoland/deno_std#182)
Original: a81d2ae1f9
This commit is contained in:
parent
fa3f8cf67b
commit
52e047138a
2 changed files with 8 additions and 1 deletions
|
@ -16,6 +16,8 @@ import { bgBlue, red, bold } from "https://deno.land/x/std/colors/mod.ts";
|
||||||
console.log(bgBlue(red(bold("Hello world!"))));
|
console.log(bgBlue(red(bold("Hello world!"))));
|
||||||
```
|
```
|
||||||
|
|
||||||
|
This module supports `NO_COLOR` environmental variable disabling any coloring if `NO_COLOR` is set.
|
||||||
|
|
||||||
## TODO
|
## TODO
|
||||||
|
|
||||||
- Currently, it just assumes it is running in an environment that supports ANSI
|
- Currently, it just assumes it is running in an environment that supports ANSI
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
|
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
|
||||||
|
import { noColor } from "deno";
|
||||||
|
|
||||||
interface Code {
|
interface Code {
|
||||||
open: string;
|
open: string;
|
||||||
|
@ -6,9 +7,13 @@ interface Code {
|
||||||
regexp: RegExp;
|
regexp: RegExp;
|
||||||
}
|
}
|
||||||
|
|
||||||
let enabled = true;
|
let enabled = !noColor;
|
||||||
|
|
||||||
export function setEnabled(value: boolean) {
|
export function setEnabled(value: boolean) {
|
||||||
|
if (noColor) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
enabled = value;
|
enabled = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue