Skip to content

Commit 79d2700

Browse files
committed
update
1 parent 80690fc commit 79d2700

File tree

1 file changed

+10
-18
lines changed

1 file changed

+10
-18
lines changed

lib/src/gen_header_coments.dart

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -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

130127
Future<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

Comments
 (0)