Fix `flutter pub -v` (#36513)
When we were running `pub` within `flutter pub`, we were
unconditionally including the `--verbosity=warning` argument.
Then we were conditionally including `--verbose` if we were
running in verbose mode. However, the former argument
supersedes the latter, and we were never able to run `pub`
in verbose mode.
diff --git a/packages/flutter_tools/lib/src/commands/update_packages.dart b/packages/flutter_tools/lib/src/commands/update_packages.dart
index fff606c..1ab8257 100644
--- a/packages/flutter_tools/lib/src/commands/update_packages.dart
+++ b/packages/flutter_tools/lib/src/commands/update_packages.dart
@@ -249,7 +249,12 @@
fakePackage.createSync();
fakePackage.writeAsStringSync(_generateFakePubspec(dependencies.values));
// First we run "pub upgrade" on this generated package:
- await pubGet(context: PubContext.updatePackages, directory: tempDir.path, upgrade: true, checkLastModified: false);
+ await pubGet(
+ context: PubContext.updatePackages,
+ directory: tempDir.path,
+ upgrade: true,
+ checkLastModified: false,
+ );
// Then we run "pub deps --style=compact" on the result. We pipe all the
// output to tree.fill(), which parses it so that it can create a graph
// of all the dependencies so that we can figure out the transitive
diff --git a/packages/flutter_tools/lib/src/dart/pub.dart b/packages/flutter_tools/lib/src/dart/pub.dart
index ca694e9..b31caf8 100644
--- a/packages/flutter_tools/lib/src/dart/pub.dart
+++ b/packages/flutter_tools/lib/src/dart/pub.dart
@@ -96,9 +96,9 @@
'Running "flutter pub $command" in ${fs.path.basename(directory)}...',
timeout: timeoutConfiguration.slowOperation,
);
+ final bool verbose = FlutterCommand.current != null && FlutterCommand.current.globalResults['verbose'];
final List<String> args = <String>[
- '--verbosity=warning',
- if (FlutterCommand.current != null && FlutterCommand.current.globalResults['verbose']) '--verbose',
+ if (verbose) '--verbose' else '--verbosity=warning',
...<String>[command, '--no-precompile'],
if (offline) '--offline',
];