diff options
Diffstat (limited to 'cli')
-rw-r--r-- | cli/main.rs | 2 | ||||
-rw-r--r-- | cli/standalone.rs | 1 | ||||
-rw-r--r-- | cli/tests/unit/tty_color_test.ts | 14 |
3 files changed, 17 insertions, 0 deletions
diff --git a/cli/main.rs b/cli/main.rs index d1f521a81..1bbc839e8 100644 --- a/cli/main.rs +++ b/cli/main.rs @@ -156,6 +156,7 @@ fn create_web_worker_callback(ps: ProcState) -> Arc<CreateWebWorkerCb> { enable_testing_features: ps.flags.enable_testing_features, location: Some(args.main_module.clone()), no_color: !colors::use_color(), + is_tty: colors::is_tty(), runtime_version: version::deno(), ts_version: version::TYPESCRIPT.to_string(), unstable: ps.flags.unstable, @@ -256,6 +257,7 @@ pub fn create_main_worker( enable_testing_features: ps.flags.enable_testing_features, location: ps.flags.location.clone(), no_color: !colors::use_color(), + is_tty: colors::is_tty(), runtime_version: version::deno(), ts_version: version::TYPESCRIPT.to_string(), unstable: ps.flags.unstable, diff --git a/cli/standalone.rs b/cli/standalone.rs index bd7bef8ac..bea29f263 100644 --- a/cli/standalone.rs +++ b/cli/standalone.rs @@ -276,6 +276,7 @@ pub async fn run( enable_testing_features: false, location: metadata.location, no_color: !colors::use_color(), + is_tty: colors::is_tty(), runtime_version: version::deno(), ts_version: version::TYPESCRIPT.to_string(), unstable: metadata.unstable, diff --git a/cli/tests/unit/tty_color_test.ts b/cli/tests/unit/tty_color_test.ts new file mode 100644 index 000000000..d64c278bf --- /dev/null +++ b/cli/tests/unit/tty_color_test.ts @@ -0,0 +1,14 @@ +// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license. +import { assertEquals } from "./test_util.ts"; + +// Note tests for Deno.setRaw is in integration tests. + +Deno.test({ permissions: { run: true } }, async function noColorIfNotTty() { + const p = Deno.run({ + cmd: [Deno.execPath(), "eval", "console.log(1)"], + stdout: "piped", + }); + const output = new TextDecoder().decode(await p.output()); + assertEquals(output, "1\n"); + p.close(); +}); |