planRun function
Chooses the packages a command runs in.
- With neither
runInPackagesnorfilters, it runs in the current package. runInPackagesselects workspace packages by name or by a glob over their paths relative to the workspace root (.is the root).filtersnarrow that selection. WithoutrunInPackages, they select from every package in the workspace.allPackagesByDefaultmakes an empty selection mean every workspace package, asdpk execdoes.
Throws a RunPlanException when a selection matches nothing.
Implementation
RunPlan planRun({
required Workspace workspace,
List<String>? runInPackages,
List<String> filters = const [],
bool allPackagesByDefault = false,
int? concurrency,
bool failFast = false,
bool dependencyOrder = false,
}) {
var selected = <WorkspacePackage>[workspace.current];
if (runInPackages != null) {
if (!workspace.isWorkspace) {
throw RunPlanException(
'run_in_packages needs a workspace, but '
'${workspace.root.relativePathOrName} has no workspace packages.',
);
}
selected = _select(workspace.allPackages, runInPackages);
if (selected.isEmpty) {
throw RunPlanException(
'run_in_packages (${runInPackages.join(', ')}) matches no workspace '
'packages. ${_available(workspace)}',
);
}
} else if (filters.isNotEmpty || allPackagesByDefault) {
selected = workspace.isWorkspace ? workspace.packages : [workspace.root];
}
if (filters.isNotEmpty) {
final candidates = runInPackages == null ? workspace.allPackages : selected;
selected = _select(candidates, filters);
if (selected.isEmpty) {
throw RunPlanException(
'--filter ${filters.join(', ')} matches no '
'${runInPackages == null ? 'workspace' : 'selected'} packages. '
'${_available(workspace)}',
);
}
}
return planPackages(
selected,
concurrency: concurrency,
failFast: failFast,
dependencyOrder: dependencyOrder,
);
}