@@ -3,7 +3,6 @@ use foundry_compilers::{
3
3
artifacts:: remappings:: Remapping ,
4
4
report:: { self , BasicStdoutReporter , Reporter } ,
5
5
} ;
6
- use foundry_config:: find_project_root;
7
6
use itertools:: Itertools ;
8
7
use semver:: Version ;
9
8
use std:: {
@@ -94,6 +93,8 @@ impl Spinner {
94
93
pub struct SpinnerReporter {
95
94
/// The sender to the spinner thread.
96
95
sender : mpsc:: Sender < SpinnerMsg > ,
96
+ /// The project root path for trimming file paths in verbose output.
97
+ project_root : Option < PathBuf > ,
97
98
}
98
99
99
100
impl SpinnerReporter {
@@ -102,7 +103,7 @@ impl SpinnerReporter {
102
103
/// The spinner's message will be updated via the `reporter` events
103
104
///
104
105
/// On drop the channel will disconnect and the thread will terminate
105
- pub fn spawn ( ) -> Self {
106
+ pub fn spawn ( project_root : Option < PathBuf > ) -> Self {
106
107
let ( sender, rx) = mpsc:: channel :: < SpinnerMsg > ( ) ;
107
108
108
109
std:: thread:: Builder :: new ( )
@@ -130,7 +131,7 @@ impl SpinnerReporter {
130
131
} )
131
132
. expect ( "failed to spawn thread" ) ;
132
133
133
- Self { sender }
134
+ Self { sender, project_root }
134
135
}
135
136
136
137
fn send_msg ( & self , msg : impl Into < String > ) {
@@ -157,14 +158,12 @@ impl Reporter for SpinnerReporter {
157
158
// Verbose message with dirty files displays first to avoid being overlapped
158
159
// by the spinner in .tick() which prints repeatedly over the same line.
159
160
if shell:: verbosity ( ) >= 5 {
160
- let project_root = find_project_root ( None ) ;
161
-
162
161
self . send_msg ( format ! (
163
162
"Files to compile:\n {}" ,
164
163
dirty_files
165
164
. iter( )
166
165
. map( |path| {
167
- let trimmed_path = if let Ok ( project_root) = & project_root {
166
+ let trimmed_path = if let Some ( project_root) = & self . project_root {
168
167
path. strip_prefix( project_root) . unwrap_or( path)
169
168
} else {
170
169
path
@@ -214,9 +213,9 @@ impl Reporter for SpinnerReporter {
214
213
/// spinning cursor to display solc progress.
215
214
///
216
215
/// If no terminal is available this falls back to common `println!` in [`BasicStdoutReporter`].
217
- pub fn with_spinner_reporter < T > ( f : impl FnOnce ( ) -> T ) -> T {
216
+ pub fn with_spinner_reporter < T > ( project_root : Option < PathBuf > , f : impl FnOnce ( ) -> T ) -> T {
218
217
let reporter = if TERM_SETTINGS . indicate_progress {
219
- report:: Report :: new ( SpinnerReporter :: spawn ( ) )
218
+ report:: Report :: new ( SpinnerReporter :: spawn ( project_root ) )
220
219
} else {
221
220
report:: Report :: new ( BasicStdoutReporter :: default ( ) )
222
221
} ;
@@ -240,7 +239,7 @@ mod tests {
240
239
241
240
#[ test]
242
241
fn can_format_properly ( ) {
243
- let r = SpinnerReporter :: spawn ( ) ;
242
+ let r = SpinnerReporter :: spawn ( None ) ;
244
243
let remappings: Vec < Remapping > = vec ! [
245
244
"library/=library/src/" . parse( ) . unwrap( ) ,
246
245
"weird-erc20/=lib/weird-erc20/src/" . parse( ) . unwrap( ) ,
0 commit comments