summary property

String get summary

The lines worth showing a user: pub's errors, else its last lines.

Implementation

String get summary {
  final lines = [
    ...LineSplitter.split(stderr),
    ...LineSplitter.split(stdout),
  ].where((l) => l.trim().isNotEmpty).toList();
  final failing = lines.where(
    (l) =>
        l.contains('Because') ||
        l.contains('version solving failed') ||
        l.startsWith('Error') ||
        l.contains('Could not'),
  );
  final pick = failing.isNotEmpty ? failing.toList() : lines;
  return pick.skip(pick.length > 12 ? pick.length - 12 : 0).join('\n');
}