discoverWayfinderQueryBundles function

Future<List<ProjectBundle>> discoverWayfinderQueryBundles(
  1. Directory workingDirectory, {
  2. String? explicitPath,
  3. String? bundleName,
})

Selects exactly one explicit bundle, or the project's configured scope.

Implementation

Future<List<ProjectBundle>> discoverWayfinderQueryBundles(
  Directory workingDirectory, {
  String? explicitPath,
  String? bundleName,
}) async {
  if (explicitPath != null && bundleName != null) {
    _invalid('Use an explicit path or bundle name, not both.');
  }
  if (explicitPath == null) {
    return (await WayfinderProject.discover(
      workingDirectory,
      bundleName: bundleName,
      searchAncestors: true,
    )).bundles;
  }
  final root = await Directory(
    p.absolute(p.join(workingDirectory.path, explicitPath)),
  ).resolveSymbolicLinks();
  final prefix = await explicitBundlePrefix(workingDirectory, root);
  return [
    ProjectBundle(
      p.basename(root),
      prefix.isEmpty
          ? p.basename(root)
          : prefix.substring(0, prefix.length - 1),
      root,
    ),
  ];
}