Fix pub remove --dry-run (#2774)
* Fix case where `pub remove foo --dry-run` might update `PUB_CACHE/global_packages/`
* Update add.dart
diff --git a/lib/src/command/add.dart b/lib/src/command/add.dart
index 36f9149..9050273 100644
--- a/lib/src/command/add.dart
+++ b/lib/src/command/add.dart
@@ -132,10 +132,14 @@
/// to this new dependency.
final newRoot = Package.inMemory(updatedPubSpec);
+ // TODO(jonasfj): Stop abusing Entrypoint.global for dry-run output
await Entrypoint.global(newRoot, entrypoint.lockFile, cache,
solveResult: solveResult)
- .acquireDependencies(SolveType.GET,
- dryRun: true, precompile: argResults['precompile']);
+ .acquireDependencies(
+ SolveType.GET,
+ dryRun: true,
+ precompile: argResults['precompile'],
+ );
} else {
/// Update the `pubspec.yaml` before calling [acquireDependencies] to
/// ensure that the modification timestamp on `pubspec.lock` and
diff --git a/lib/src/command/remove.dart b/lib/src/command/remove.dart
index fdf3f46..9ed4ebe 100644
--- a/lib/src/command/remove.dart
+++ b/lib/src/command/remove.dart
@@ -57,8 +57,11 @@
final newRoot = Package.inMemory(newPubspec);
await Entrypoint.global(newRoot, entrypoint.lockFile, cache)
- .acquireDependencies(SolveType.GET,
- precompile: argResults['precompile']);
+ .acquireDependencies(
+ SolveType.GET,
+ precompile: argResults['precompile'],
+ dryRun: true,
+ );
} else {
/// Update the pubspec.
_writeRemovalToPubspec(packages);