diff --git a/Cargo.lock b/Cargo.lock index 1922c69b89af..7dc745cbf0de 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3716,6 +3716,7 @@ dependencies = [ "foundry-compilers", "foundry-config", "foundry-macros", + "itertools 0.13.0", "num-format", "reqwest", "semver 1.0.23", diff --git a/crates/common/Cargo.toml b/crates/common/Cargo.toml index 8fa745a13982..033c53e49dba 100644 --- a/crates/common/Cargo.toml +++ b/crates/common/Cargo.toml @@ -50,6 +50,7 @@ clap = { version = "4", features = ["derive", "env", "unicode", "wrap_help"] } comfy-table.workspace = true dunce.workspace = true eyre.workspace = true +itertools.workspace = true num-format.workspace = true reqwest.workspace = true semver.workspace = true diff --git a/crates/common/src/term.rs b/crates/common/src/term.rs index ead39b5face3..e673987454cb 100644 --- a/crates/common/src/term.rs +++ b/crates/common/src/term.rs @@ -3,6 +3,8 @@ use foundry_compilers::{ artifacts::remappings::Remapping, report::{self, BasicStdoutReporter, Reporter}, }; +use foundry_config::find_project_root; +use itertools::Itertools; use semver::Version; use std::{ io, @@ -17,6 +19,8 @@ use std::{ }; use yansi::Paint; +use crate::shell; + /// Some spinners // https://github.com/gernest/wow/blob/master/spin/spinners.go pub static SPINNERS: &[&[&str]] = &[ @@ -151,6 +155,24 @@ impl Drop for SpinnerReporter { impl Reporter for SpinnerReporter { fn on_compiler_spawn(&self, compiler_name: &str, version: &Version, dirty_files: &[PathBuf]) { + // Verbose message with dirty files displays first to avoid being overlapped + // by the spinner in .tick() which prints repeatedly over the same line. + if shell::verbosity() >= 5 { + let project_root = find_project_root(None); + + self.send_msg(format!( + "Files to compile:\n{}", + dirty_files + .iter() + .map(|path| { + let trimmed_path = path.strip_prefix(&project_root).unwrap_or(path); + format!("- {}", trimmed_path.display()) + }) + .sorted() + .format("\n") + )); + } + self.send_msg(format!( "Compiling {} files with {} {}.{}.{}", dirty_files.len(),