plan method

IncrementalGenerationPlan plan({
  1. required List<File> specs,
  2. required List<String> outputPathsForSpec(
    1. File spec
    ),
})

Implementation

IncrementalGenerationPlan plan({
  required List<File> specs,
  required List<String> Function(File spec) outputPathsForSpec,
}) {
  final manifest = _readManifest();
  final changed = <File>[];
  for (final spec in specs) {
    final rel = p.relative(spec.path, from: projectRoot);
    final hash = contentHash(spec);
    final entry = manifest[rel];
    final cachedHash = entry is Map<String, dynamic> ? entry['hash'] as String? : null;
    final outputPaths = outputPathsForSpec(spec);
    final missingOutput = outputPaths.any((path) => !File(path).existsSync());
    if (cachedHash != hash || missingOutput) {
      changed.add(spec);
    }
  }
  return IncrementalGenerationPlan(List.unmodifiable(changed));
}