1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
import { assertEquals } from "./test_util.ts";
// Note tests for Deno.stdin.setRaw is in integration tests.
Deno.test(
{ permissions: { run: true, read: true } },
async function noColorIfNotTty() {
const { stdout } = await new Deno.Command(Deno.execPath(), {
args: ["eval", "console.log(1)"],
}).output();
const output = new TextDecoder().decode(stdout);
assertEquals(output, "1\n");
},
);
Deno.test(
{ permissions: { run: true, read: true } },
async function denoNoColorIsNotAffectedByNonTty() {
const { stdout } = await new Deno.Command(Deno.execPath(), {
args: ["eval", "console.log(Deno.noColor)"],
}).output();
const output = new TextDecoder().decode(stdout);
assertEquals(output, "false\n");
},
);
Deno.test(
{ permissions: { run: true, read: true } },
async function denoNoColorTrueEmptyVar() {
const { stdout } = await new Deno.Command(Deno.execPath(), {
args: ["eval", "console.log(Deno.noColor)"],
env: {
// https://no-color.org/ -- should not be true when empty
NO_COLOR: "",
},
}).output();
const output = new TextDecoder().decode(stdout);
assertEquals(output, "false\n");
},
);
Deno.test(
{ permissions: { run: true, read: true } },
async function denoNoColorTrueEmptyVar() {
const { stdout } = await new Deno.Command(Deno.execPath(), {
args: ["eval", "console.log(Deno.noColor)"],
env: {
NO_COLOR: "1",
},
}).output();
const output = new TextDecoder().decode(stdout);
assertEquals(output, "true\n");
},
);
|