Skip to content

Commit

Permalink
fix(fmt): Allow styling on the Pipe
Browse files Browse the repository at this point in the history
  • Loading branch information
epage committed Jan 18, 2024
1 parent 4276f5f commit 730b0a0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
4 changes: 4 additions & 0 deletions src/fmt/writer/buffer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,10 @@ impl BufferWriter {
eprint!("{}", buf);
}
WritableTarget::Pipe(pipe) => {
#[cfg(feature = "color")]
let buf = adapt(buf, self.write_style)?;
#[cfg(feature = "color")]
let buf = &buf;
let mut stream = pipe.lock().unwrap();
stream.write_all(buf)?;
stream.flush()?;
Expand Down
7 changes: 1 addition & 6 deletions src/fmt/writer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,16 +129,11 @@ impl Builder {
match &self.target {
Target::Stdout => anstream::AutoStream::choice(&std::io::stdout()).into(),
Target::Stderr => anstream::AutoStream::choice(&std::io::stderr()).into(),
Target::Pipe(_) => WriteStyle::Never,
Target::Pipe(_) => color_choice,
}
} else {
color_choice
};
let color_choice = match &self.target {
Target::Stdout => color_choice,
Target::Stderr => color_choice,
Target::Pipe(_) => WriteStyle::Never,
};
let color_choice = if color_choice == WriteStyle::Auto {
WriteStyle::Never
} else {
Expand Down

0 comments on commit 730b0a0

Please sign in to comment.