@@ -94,10 +94,7 @@ Future<void> genHeaderComments(
9494 String templateData;
9595 _print (Log .printWhite, 'Reading template at: $template ...' );
9696
97- final result =
98- (await MdTemplateUtility .i.readTemplateFromPathOrUrl (template).toSync ())
99- // ignore: invalid_use_of_visible_for_testing_member
100- .value;
97+ final result = (await MdTemplateUtility .i.readTemplateFromPathOrUrl (template).value);
10198
10299 if (result.isErr ()) {
103100 spinner.stop ();
@@ -128,28 +125,23 @@ Future<void> genHeaderComments(
128125// ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
129126
130127Future <void > _generateForFile (String filePath, String template) async {
131- final commentStarter =
132- langFileCommentStarters[p.extension (filePath).toLowerCase ()] ?? '//' ;
128+ final commentStarter = langFileCommentStarters[p.extension (filePath).toLowerCase ()] ?? '//' ;
133129 var templateLines = template.split ('\n ' );
134- final sourceLines =
135- (await FileSystemUtility .i.readLocalFileAsLinesOrNull (filePath)) ?? [];
130+ final sourceLines = (await FileSystemUtility .i.readLocalFileAsLinesOrNull (filePath)) ?? [];
136131 if (sourceLines.isNotEmpty) {
137132 // Replace leading '//' in all template lines with the comment starter
138- templateLines =
139- templateLines.map ((line) {
140- if (line.trim ().startsWith ('//' )) {
141- return commentStarter +
142- line.substring (2 ); // Replace leading // only
143- }
144- return line; // Return the line unchanged if it doesn't start with //
145- }).toList ();
133+ templateLines = templateLines.map ((line) {
134+ if (line.trim ().startsWith ('//' )) {
135+ return commentStarter + line.substring (2 ); // Replace leading // only
136+ }
137+ return line; // Return the line unchanged if it doesn't start with //
138+ }).toList ();
146139
147140 for (var n = 0 ; n < sourceLines.length; n++ ) {
148141 final line = sourceLines[n].trim ();
149142 if (line.isEmpty || ! line.startsWith (commentStarter)) {
150143 final withoutHeader = sourceLines.sublist (n).join ('\n ' );
151- final withHeader =
152- '${templateLines .join ('\n ' )}\n\n ${withoutHeader .trimLeft ()}\n ' ;
144+ final withHeader = '${templateLines .join ('\n ' )}\n\n ${withoutHeader .trimLeft ()}\n ' ;
153145 await FileSystemUtility .i.writeLocalFile (filePath, withHeader);
154146 break ;
155147 }
0 commit comments