Skip to content

Commit 43de8e3

Browse files
mgiagantemgiagantezerosnacksDaniPopes
authored andcommitted
feat(forge build -vvvvv): If verbosity level is 5 or higher show files to compile (foundry-rs#9325)
* If verbosity level is 1 or higher, it shows dirty files. * Adds verbose message variant for compilation. * Removing `if..else` statement to always display `self.send_msg`. * Changes order of messages. * Removes semicolons and adds comment on message order. * Removes verbose variant in favor of the already existing variant. * nits, sort the dirty files list and prefix with - * Raises verbosity level to 5+ * Update crates/common/src/term.rs Co-authored-by: DaniPopes <[email protected]> --------- Co-authored-by: mgiagante <[email protected]> Co-authored-by: zerosnacks <[email protected]> Co-authored-by: DaniPopes <[email protected]>
1 parent a26cfe7 commit 43de8e3

File tree

3 files changed

+24
-0
lines changed

3 files changed

+24
-0
lines changed

Cargo.lock

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/common/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ clap = { version = "4", features = ["derive", "env", "unicode", "wrap_help"] }
5050
comfy-table.workspace = true
5151
dunce.workspace = true
5252
eyre.workspace = true
53+
itertools.workspace = true
5354
num-format.workspace = true
5455
reqwest.workspace = true
5556
semver.workspace = true

crates/common/src/term.rs

+22
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ use foundry_compilers::{
33
artifacts::remappings::Remapping,
44
report::{self, BasicStdoutReporter, Reporter},
55
};
6+
use foundry_config::find_project_root;
7+
use itertools::Itertools;
68
use semver::Version;
79
use std::{
810
io,
@@ -17,6 +19,8 @@ use std::{
1719
};
1820
use yansi::Paint;
1921

22+
use crate::shell;
23+
2024
/// Some spinners
2125
// https://github.com/gernest/wow/blob/master/spin/spinners.go
2226
pub static SPINNERS: &[&[&str]] = &[
@@ -151,6 +155,24 @@ impl Drop for SpinnerReporter {
151155

152156
impl Reporter for SpinnerReporter {
153157
fn on_compiler_spawn(&self, compiler_name: &str, version: &Version, dirty_files: &[PathBuf]) {
158+
// Verbose message with dirty files displays first to avoid being overlapped
159+
// by the spinner in .tick() which prints repeatedly over the same line.
160+
if shell::verbosity() >= 5 {
161+
let project_root = find_project_root(None);
162+
163+
self.send_msg(format!(
164+
"Files to compile:\n{}",
165+
dirty_files
166+
.iter()
167+
.map(|path| {
168+
let trimmed_path = path.strip_prefix(&project_root).unwrap_or(path);
169+
format!("- {}", trimmed_path.display())
170+
})
171+
.sorted()
172+
.format("\n")
173+
));
174+
}
175+
154176
self.send_msg(format!(
155177
"Compiling {} files with {} {}.{}.{}",
156178
dirty_files.len(),

0 commit comments

Comments
 (0)