@@ -13,7 +13,7 @@ use foundry_compilers_artifacts::{
13
13
} ;
14
14
use foundry_compilers_core:: {
15
15
error:: { Result , SolcError , SolcIoError } ,
16
- utils,
16
+ utils:: { self , strip_prefix_owned } ,
17
17
} ;
18
18
use serde:: { Deserialize , Serialize } ;
19
19
use std:: {
@@ -661,27 +661,25 @@ impl ProjectPaths {
661
661
662
662
/// Removes `base` from all folders
663
663
pub fn strip_prefix_all ( & mut self , base : & Path ) -> & mut Self {
664
- if let Ok ( prefix ) = self . artifacts . strip_prefix ( base) {
665
- self . artifacts = prefix . to_path_buf ( ) ;
664
+ if let Ok ( stripped ) = self . artifacts . strip_prefix ( base) {
665
+ self . artifacts = stripped . to_path_buf ( ) ;
666
666
}
667
- if let Ok ( prefix ) = self . build_infos . strip_prefix ( base) {
668
- self . build_infos = prefix . to_path_buf ( ) ;
667
+ if let Ok ( stripped ) = self . build_infos . strip_prefix ( base) {
668
+ self . build_infos = stripped . to_path_buf ( ) ;
669
669
}
670
- if let Ok ( prefix ) = self . sources . strip_prefix ( base) {
671
- self . sources = prefix . to_path_buf ( ) ;
670
+ if let Ok ( stripped ) = self . sources . strip_prefix ( base) {
671
+ self . sources = stripped . to_path_buf ( ) ;
672
672
}
673
- if let Ok ( prefix ) = self . tests . strip_prefix ( base) {
674
- self . tests = prefix . to_path_buf ( ) ;
673
+ if let Ok ( stripped ) = self . tests . strip_prefix ( base) {
674
+ self . tests = stripped . to_path_buf ( ) ;
675
675
}
676
- if let Ok ( prefix ) = self . scripts . strip_prefix ( base) {
677
- self . scripts = prefix . to_path_buf ( ) ;
676
+ if let Ok ( stripped ) = self . scripts . strip_prefix ( base) {
677
+ self . scripts = stripped . to_path_buf ( ) ;
678
678
}
679
- let libraries = std:: mem:: take ( & mut self . libraries ) ;
680
- self . libraries . extend (
681
- libraries
682
- . into_iter ( )
683
- . map ( |p| p. strip_prefix ( base) . map ( |p| p. to_path_buf ( ) ) . unwrap_or ( p) ) ,
684
- ) ;
679
+ self . libraries = std:: mem:: take ( & mut self . libraries )
680
+ . into_iter ( )
681
+ . map ( |path| strip_prefix_owned ( path, base) )
682
+ . collect ( ) ;
685
683
self
686
684
}
687
685
}
0 commit comments