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", "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]] [[package]]
name = "console" name = "console"
version = "0.14.1" version = "0.14.1"
@ -1467,7 +1456,6 @@ name = "ethers-solc"
version = "0.17.0" version = "0.17.0"
dependencies = [ dependencies = [
"cfg-if 1.0.0", "cfg-if 1.0.0",
"colored",
"criterion", "criterion",
"dunce", "dunce",
"env_logger", "env_logger",
@ -1500,6 +1488,7 @@ dependencies = [
"tracing", "tracing",
"tracing-subscriber", "tracing-subscriber",
"walkdir", "walkdir",
"yansi",
] ]
[[package]] [[package]]

View File

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

View File

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