write method

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

Implementation

void write({
  required List<File> specs,
  required List<String> Function(File spec) outputPathsForSpec,
}) {
  final manifest = <String, Object>{};
  for (final spec in specs) {
    final rel = p.relative(spec.path, from: projectRoot);
    manifest[rel] = {
      'hash': contentHash(spec),
      'outputFiles': outputPathsForSpec(spec).map((path) => p.relative(path, from: projectRoot)).toList(),
    };
  }
  manifestFile.parent.createSync(recursive: true);
  const encoder = JsonEncoder.withIndent('  ');
  manifestFile.writeAsStringSync('${encoder.convert(manifest)}\n');
}