selectExactMainLibrary function
Implementation
File selectExactMainLibrary(
Iterable<File> candidates, {
required String expectedBasename,
required String platform,
}) {
final matches =
_uniqueFiles(
candidates,
).where((file) => p.basename(file.path) == expectedBasename).toList()
..sort((a, b) => a.path.compareTo(b.path));
if (matches.isEmpty) {
final available = _uniqueFiles(
candidates,
).map((file) => p.basename(file.path)).toSet().toList()..sort();
throw StateError(
'$platform artifact must contain exactly one $expectedBasename; '
'available files: ${available.isEmpty ? '(none)' : available.join(', ')}',
);
}
if (matches.length > 1) {
throw StateError(
'$platform artifact contains multiple $expectedBasename files: '
'${matches.map((file) => file.path).join(', ')}',
);
}
return matches.single;
}