@@ -561,6 +561,9 @@ async function runAutofixForRepository(
561
561
) ;
562
562
}
563
563
564
+ // Format the output text file with markdown.
565
+ await formatWithMarkdown ( outputTextFilePath , `${ nwo } ` ) ;
566
+
564
567
// Save output text files from each repo to later merge
565
568
// into a single markdown file containing all results.
566
569
outputTextFiles . push ( outputTextFilePath ) ;
@@ -750,3 +753,39 @@ async function mergeFiles(
750
753
throw error ;
751
754
}
752
755
}
756
+
757
+ /**
758
+ * Formats the given input file with the specified header.
759
+ * @param inputFile The path to the input file to format.
760
+ * @param header The header to include in the formatted output.
761
+ */
762
+ async function formatWithMarkdown (
763
+ inputFile : string ,
764
+ header : string ,
765
+ ) : Promise < void > {
766
+ try {
767
+ // Check if the input file exists
768
+ const exists = await pathExists ( inputFile ) ;
769
+ if ( ! exists ) {
770
+ return ;
771
+ }
772
+
773
+ // Read the input file content
774
+ const content = await readFile ( inputFile , "utf8" ) ;
775
+
776
+ const frontFormatting : string =
777
+ "<details><summary>Fix suggestion details</summary>\n\n```diff\n" ;
778
+
779
+ const backFormatting : string =
780
+ "```\n\n</details>\n\n ### Notes\n - notes placeholder\n\n" ;
781
+
782
+ // Format the content with Markdown
783
+ const formattedContent = `## ${ header } \n\n${ frontFormatting } ${ content } ${ backFormatting } ` ;
784
+
785
+ // Write the formatted content back to the file
786
+ await writeFile ( inputFile , formattedContent ) ;
787
+ } catch ( error ) {
788
+ console . error ( "Error formatting file:" , error ) ;
789
+ throw error ;
790
+ }
791
+ }
0 commit comments