Skip to content

Commit fdac4be

Browse files
authored
fix(patchable): Only print ANSI if stdout is terminal (#1458)
1 parent 14b6312 commit fdac4be

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

rust/patchable/src/main.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,11 @@ mod repo;
55
mod utils;
66

77
use core::str;
8-
use std::{fs::File, io::Write, path::PathBuf};
8+
use std::{
9+
fs::File,
10+
io::{IsTerminal, Write},
11+
path::PathBuf,
12+
};
913

1014
use git2::{Oid, Repository};
1115
use serde::{Deserialize, Serialize};
@@ -327,7 +331,11 @@ type Result<T, E = Error> = std::result::Result<T, E>;
327331
#[snafu::report]
328332
fn main() -> Result<()> {
329333
tracing_subscriber::registry()
330-
.with(tracing_subscriber::fmt::layer().with_writer(std::io::stderr))
334+
.with(
335+
tracing_subscriber::fmt::layer()
336+
.with_ansi(std::io::stdout().is_terminal())
337+
.with_writer(std::io::stderr),
338+
)
331339
.with(IndicatifLayer::new())
332340
.with(
333341
tracing_subscriber::EnvFilter::builder()

0 commit comments

Comments
 (0)