scanAll static method

List<Checkout> scanAll(
  1. Iterable<Directory> dirs
)

The ecosystem packages in each of dirs — say a workspace's packages/ and plugins/ — in name order. A package checked out in two of them throws DevLinkClash: which one to link is for the developer to say.

Implementation

static List<Checkout> scanAll(Iterable<Directory> dirs) {
  final byName = <String, Checkout>{};
  for (final dir in dirs) {
    for (final c in scan(dir)) {
      final seen = byName[c.name];
      if (seen != null && seen.path != c.path) {
        throw DevLinkClash(c.name, [seen.path, c.path]);
      }
      byName[c.name] = c;
    }
  }
  return byName.values.toList()..sort((a, b) => a.name.compareTo(b.name));
}