Be more quiet when doing implicit pub get (#3847)
diff --git a/lib/pub.dart b/lib/pub.dart
index b1239f7..0dd0e90 100644
--- a/lib/pub.dart
+++ b/lib/pub.dart
@@ -32,15 +32,25 @@
/// .dart_tool/package_config.json are up-to-date and all packages are
/// downloaded to the cache.
///
-/// Will attempt
+/// Will compare file timestamps to see if full resolution can be skipped.
+///
+/// If [summaryOnly] is `true` (the default) only a short summary is shown of
+/// the solve.
+///
+/// If [onlyOutputWhenTerminal] is `true` (the default) there will be no
+/// output if no terminal is attached.
Future<void> ensurePubspecResolved(
String dir, {
PubAnalytics? analytics,
bool isOffline = false,
bool checkForSdkUpdate = false,
+ bool summaryOnly = true,
+ bool onlyOutputWhenTerminal = true,
}) async {
await Entrypoint(dir, SystemCache(isOffline: isOffline)).ensureUpToDate(
analytics: analytics,
checkForSdkUpdate: checkForSdkUpdate,
+ summaryOnly: summaryOnly,
+ onlyOutputWhenTerminal: onlyOutputWhenTerminal,
);
}
diff --git a/lib/src/entrypoint.dart b/lib/src/entrypoint.dart
index f92ff26..c4cf03e 100644
--- a/lib/src/entrypoint.dart
+++ b/lib/src/entrypoint.dart
@@ -603,18 +603,40 @@
}
}
- /// Does a fast-pass check to see if the resolution is up-to-date ([_isUpToDate]).
- /// If not, run a resolution with `pub get` semantics.
+ /// Does a fast-pass check to see if the resolution is up-to-date
+ /// ([_isUpToDate]). If not, run a resolution with `pub get` semantics.
///
/// If [checkForSdkUpdate] is `true`, the resolution is considered outdated if
/// the package_config.json was created by a different sdk. See
/// [_isPackageConfigGeneratedBySameDartSdk].
+ ///
+ /// If [summaryOnly] is `true` (the default) only a short summary is shown of
+ /// the solve.
+ ///
+ /// If [onlyOutputWhenTerminal] is `true` (the default) there will be no
+ /// output if no terminal is attached.
Future<void> ensureUpToDate({
bool checkForSdkUpdate = false,
PubAnalytics? analytics,
+ bool summaryOnly = true,
+ bool onlyOutputWhenTerminal = true,
}) async {
if (!_isUpToDate(checkForSdkUpdate: checkForSdkUpdate)) {
- await acquireDependencies(SolveType.get, analytics: analytics);
+ if (onlyOutputWhenTerminal) {
+ await log.errorsOnlyUnlessTerminal(() async {
+ await acquireDependencies(
+ SolveType.get,
+ analytics: analytics,
+ summaryOnly: summaryOnly,
+ );
+ });
+ } else {
+ await acquireDependencies(
+ SolveType.get,
+ analytics: analytics,
+ summaryOnly: summaryOnly,
+ );
+ }
} else {
log.fine('Package Config up to date.');
}
diff --git a/test/embedding/embedding_test.dart b/test/embedding/embedding_test.dart
index 4b8e7ac..480acae 100644
--- a/test/embedding/embedding_test.dart
+++ b/test/embedding/embedding_test.dart
@@ -394,7 +394,6 @@
buffer.toString(),
allOf(
contains('Resolving dependencies'),
- contains('+ foo 1.0.0'),
contains('42'),
),
);