withUpdatedRootPubspecs method

Entrypoint withUpdatedRootPubspecs(
  1. Map<Package, Pubspec> updatedPubspecs
)

Creates an entrypoint at the same location, but with each pubspec in updatedPubspecs replacing the with one for the corresponding package.

Implementation

Entrypoint withUpdatedRootPubspecs(Map<Package, Pubspec> updatedPubspecs) {
  final newWorkspaceRoot = workspaceRoot.transformWorkspace(
    (package) => updatedPubspecs[package] ?? package.pubspec,
  );
  final newWorkPackage = newWorkspaceRoot.transitiveWorkspace
      .firstWhere((package) => package.dir == workPackage.dir);
  return Entrypoint._(
    workingDir,
    _lockFile,
    _example,
    _packageGraph,
    cache,
    (root: newWorkspaceRoot, work: newWorkPackage),
    isCachedGlobal,
  );
}