chore(solc): replace colorized with yansi (#1662)

This commit is contained in:
Matthias Seitz 2022-09-04 20:00:11 +02:00 committed by GitHub
parent 744d5c055e
commit e425b55c92
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 20 deletions

13
Cargo.lock generated
View File

@ -663,17 +663,6 @@ dependencies = [
"wasm-bindgen-futures",
]
[[package]]
name = "colored"
version = "2.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b3616f750b84d8f0de8a58bda93e08e2a81ad3f523089b05f1dffecab48c6cbd"
dependencies = [
"atty",
"lazy_static",
"winapi",
]
[[package]]
name = "console"
version = "0.14.1"
@ -1467,7 +1456,6 @@ name = "ethers-solc"
version = "0.17.0"
dependencies = [
"cfg-if 1.0.0",
"colored",
"criterion",
"dunce",
"env_logger",
@ -1500,6 +1488,7 @@ dependencies = [
"tracing",
"tracing-subscriber",
"walkdir",
"yansi",
]
[[package]]

View File

@ -26,7 +26,7 @@ regex = "1.6.0"
md-5 = "0.10.2"
thiserror = "1.0"
hex = "0.4.3"
colored = "2.0.0"
yansi = "0.5.1"
glob = "0.3.0"
tracing = "0.1.36"
num_cpus = "1.13.1"

View File

@ -2,7 +2,6 @@
use crate::{
compile::*, error::SolcIoError, remappings::Remapping, utils, ProjectPathsConfig, SolcError,
};
use colored::Colorize;
use ethers_core::abi::Abi;
use md5::Digest;
use semver::{Version, VersionReq};
@ -14,6 +13,7 @@ use std::{
str::FromStr,
};
use tracing::warn;
use yansi::Paint;
pub mod ast;
pub use ast::*;
@ -1687,15 +1687,15 @@ impl fmt::Display for Error {
match self.severity {
Severity::Error => {
if let Some(code) = self.error_code {
format!("error[{}]: ", code).as_str().red().fmt(f)?;
Paint::red(format!("error[{}]: ", code)).fmt(f)?;
}
msg.as_str().red().fmt(f)
Paint::red(msg).fmt(f)
}
Severity::Warning | Severity::Info => {
if let Some(code) = self.error_code {
format!("warning[{}]: ", code).as_str().yellow().fmt(f)?;
Paint::yellow(format!("warning[{}]: ", code)).fmt(f)?;
}
msg.as_str().yellow().fmt(f)
Paint::yellow(msg).fmt(f)
}
}
} else {
@ -1715,8 +1715,8 @@ pub enum Severity {
impl fmt::Display for Severity {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Severity::Error => f.write_str(&"Error".red()),
Severity::Warning => f.write_str(&"Warning".yellow()),
Severity::Error => Paint::red("Error").fmt(f),
Severity::Warning => Paint::yellow("Warning").fmt(f),
Severity::Info => f.write_str("Info"),
}
}