Omit colors when writing to output file (#186)

We were writing color escape codes to the file specified by `-o`.
This commit is contained in:
Charlie Marsh 2023-10-25 21:12:25 -07:00 committed by GitHub
parent 61a61db154
commit 9f894213e0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -126,6 +126,10 @@ pub(crate) async fn pip_compile(
.dimmed()
)?;
if output_file.is_some() {
colored::control::set_override(false);
}
let mut writer: Box<dyn std::io::Write> = if let Some(output_file) = output_file {
Box::new(BufWriter::new(File::create(output_file)?))
} else {
@ -145,5 +149,9 @@ pub(crate) async fn pip_compile(
)?;
write!(writer, "{resolution}")?;
if output_file.is_some() {
colored::control::unset_override();
}
Ok(ExitStatus::Success)
}