cleanOldBins function

void cleanOldBins(
  1. Directory binDir,
  2. Iterable yamlKeys
)

Implementation

void cleanOldBins(Directory binDir, Iterable yamlKeys) {
  final existingBins = binDir.existsSync() ? binDir.listSync().whereType<File>().toList() : [];
  final yamlSet = yamlKeys.toSet();
  for (final file in existingBins) {
    final name = file.uri.pathSegments.last.replaceAll('.dart', '');
    if (!yamlSet.contains(name)) {
      file.deleteSync();
    }
  }
}