pendingBuildRunnerFiles method

List<String> pendingBuildRunnerFiles(
  1. List<String> modifiedFilePaths
)

Given a list of source files that were rewritten, returns those that now contain a part '*.g.dart'; directive and therefore need build_runner.

Implementation

List<String> pendingBuildRunnerFiles(List<String> modifiedFilePaths) {
  final pending = <String>[];
  for (final path in modifiedFilePaths) {
    final file = File(path);
    if (!file.existsSync()) continue;
    final content = file.readAsStringSync();
    if (RegExp(r"part '[^']+\.g\.dart';").hasMatch(content)) {
      pending.add(path);
    }
  }
  return pending;
}