🐛 Only format Dart files for gen-l10n (#131232)

Improves #119596. The tests remain valid, so no tests were updated in the request.

This does not resolve issue #128932, it's handled by another part of the code.
This commit is contained in:
Alex Li
2023-07-28 04:04:07 +08:00
committed by GitHub
parent e099d67c7b
commit eab2087a0f

View File

@@ -80,15 +80,11 @@ Future<LocalizationsGenerator> generateLocalizations({
throwToolExit(e.message);
}
final List<String> outputFileList = generator.outputFileList;
final File? untranslatedMessagesFile = generator.untranslatedMessagesFile;
if (options.format) {
final List<String> formatFileList = outputFileList.toList();
if (untranslatedMessagesFile != null) {
// Don't format the messages file using `dart format`.
formatFileList.remove(untranslatedMessagesFile.absolute.path);
}
// Only format Dart files using `dart format`.
final List<String> formatFileList = generator.outputFileList
.where((String e) => e.endsWith('.dart'))
.toList(growable: false);
if (formatFileList.isEmpty) {
return generator;
}