File tree Expand file tree Collapse file tree 1 file changed +11
-4
lines changed Expand file tree Collapse file tree 1 file changed +11
-4
lines changed Original file line number Diff line number Diff line change @@ -678,6 +678,14 @@ edition = {}
678
678
679
679
// Create all specified source files (with respective parent directories) if they don't exist.
680
680
681
+ let rustfmt_exists = match Command :: new ( "rustfmt" ) . arg ( "-V" ) . output ( ) {
682
+ Ok ( _) => true ,
683
+ Err ( e) => {
684
+ log:: warn!( "rustfmt not found: {}" , e) ;
685
+ false
686
+ }
687
+ } ;
688
+
681
689
for i in & opts. source_files {
682
690
let path_of_source_file = path. join ( i. relative_path . clone ( ) ) ;
683
691
@@ -709,10 +717,9 @@ mod tests {
709
717
{
710
718
paths:: write ( & path_of_source_file, default_file_content) ?;
711
719
712
- // Format the newly created source file with rustfmt
713
- if let Err ( e) = Command :: new ( "rustfmt" ) . arg ( & path_of_source_file) . output ( ) {
714
- let msg = format ! ( "failed to format {}: {}" , path_of_source_file. display( ) , e) ;
715
- config. shell ( ) . warn ( msg) ?;
720
+ // Format the newly created source file
721
+ if rustfmt_exists {
722
+ Command :: new ( "rustfmt" ) . arg ( & path_of_source_file) . output ( ) ?;
716
723
}
717
724
}
718
725
}
You can’t perform that action at this time.
0 commit comments