Skip to content

Commit 445dbc4

Browse files
committed
replace enum with simpler boolean
1 parent b33c5fd commit 445dbc4

File tree

8 files changed

+22
-24
lines changed

8 files changed

+22
-24
lines changed

packages/flutter_tools/lib/src/commands/create.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,7 @@ class CreateCommand extends CreateBase {
414414
context: pubContext,
415415
project: project,
416416
offline: boolArgDeprecated('offline'),
417-
outputMode: PubOutputMode.summaryOnly,
417+
printProgress: false,
418418
);
419419
await project.ensureReadyForPlatformSpecificTooling(
420420
androidPlatform: includeAndroid,

packages/flutter_tools/lib/src/commands/update_packages.dart

+2-2
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,7 @@ class UpdatePackagesCommand extends FlutterCommand {
444444
upgrade: doUpgrade,
445445
offline: boolArgDeprecated('offline'),
446446
flutterRootOverride: temporaryFlutterSdk?.path,
447-
outputMode: PubOutputMode.none,
447+
printProgress: false,
448448
);
449449

450450
if (doUpgrade) {
@@ -538,7 +538,7 @@ class UpdatePackagesCommand extends FlutterCommand {
538538
// All dependencies should already have been downloaded by the fake
539539
// package, so the concurrent checks can all happen offline.
540540
offline: true,
541-
outputMode: PubOutputMode.none,
541+
printProgress: false,
542542
);
543543
stopwatch.stop();
544544
final double seconds = stopwatch.elapsedMilliseconds / 1000.0;

packages/flutter_tools/lib/src/dart/pub.dart

+13-15
Original file line numberDiff line numberDiff line change
@@ -140,12 +140,6 @@ class PubContext {
140140
}
141141
}
142142

143-
enum PubOutputMode {
144-
none,
145-
standard,
146-
summaryOnly,
147-
}
148-
149143
/// A handle for interacting with the pub tool.
150144
abstract class Pub {
151145
/// Create a default [Pub] instance.
@@ -178,6 +172,10 @@ abstract class Pub {
178172
/// If [shouldSkipThirdPartyGenerator] is true, the overall pub get will be
179173
/// skipped if the package config file has a "generator" other than "pub".
180174
/// Defaults to true.
175+
///
176+
/// If [printProgress] is true, `pub get` will inherit stdio from the current process.
177+
/// Defaults to true.
178+
///
181179
/// Will also resolve dependencies in the example folder if present.
182180
Future<void> get({
183181
required PubContext context,
@@ -187,7 +185,7 @@ abstract class Pub {
187185
String? flutterRootOverride,
188186
bool checkUpToDate = false,
189187
bool shouldSkipThirdPartyGenerator = true,
190-
PubOutputMode outputMode = PubOutputMode.standard
188+
bool printProgress = true,
191189
});
192190

193191
/// Runs pub in 'batch' mode.
@@ -227,7 +225,7 @@ abstract class Pub {
227225
required String command,
228226
bool touchesPackageConfig = false,
229227
bool generateSyntheticPackage = false,
230-
PubOutputMode outputMode = PubOutputMode.standard
228+
bool printProgress = true,
231229
});
232230
}
233231

@@ -292,7 +290,7 @@ class _DefaultPub implements Pub {
292290
String? flutterRootOverride,
293291
bool checkUpToDate = false,
294292
bool shouldSkipThirdPartyGenerator = true,
295-
PubOutputMode outputMode = PubOutputMode.standard
293+
bool printProgress = true,
296294
}) async {
297295
final String directory = project.directory.path;
298296
final File packageConfigFile = project.packageConfigFile;
@@ -364,7 +362,7 @@ class _DefaultPub implements Pub {
364362
directory: directory,
365363
failureMessage: 'pub $command failed',
366364
flutterRootOverride: flutterRootOverride,
367-
outputMode: outputMode,
365+
printProgress: printProgress,
368366
);
369367
await _updateVersionAndPackageConfig(project);
370368
}
@@ -381,19 +379,19 @@ class _DefaultPub implements Pub {
381379
Future<void> _runWithStdioInherited(
382380
List<String> arguments, {
383381
required String command,
384-
required PubOutputMode outputMode,
385382
required PubContext context,
386383
required String directory,
387384
String failureMessage = 'pub failed',
388385
String? flutterRootOverride,
386+
bool printProgress = true
389387
}) async {
390388
int exitCode;
391389

392390
final List<String> pubCommand = _pubCommand(arguments);
393-
final Map<String, String> pubEnvironment = await _createPubEnvironment(context: context, flutterRootOverride: flutterRootOverride, summaryOnly: outputMode == PubOutputMode.summaryOnly);
391+
final Map<String, String> pubEnvironment = await _createPubEnvironment(context: context, flutterRootOverride: flutterRootOverride, summaryOnly: printProgress);
394392

395393
try {
396-
if (outputMode != PubOutputMode.none) {
394+
if (printProgress) {
397395
final io.Stdio? stdio = _stdio;
398396
if (stdio == null) {
399397
// Let pub inherit stdio and output directly to the tool's stdout and
@@ -564,14 +562,14 @@ class _DefaultPub implements Pub {
564562
required String command,
565563
bool touchesPackageConfig = false,
566564
bool generateSyntheticPackage = false,
567-
PubOutputMode outputMode = PubOutputMode.standard
565+
bool printProgress = true,
568566
}) async {
569567
await _runWithStdioInherited(
570568
arguments,
571569
command: command,
572570
directory: _fileSystem.currentDirectory.path,
573571
context: context,
574-
outputMode: outputMode,
572+
printProgress: printProgress,
575573
);
576574
if (touchesPackageConfig && project != null) {
577575
await _updateVersionAndPackageConfig(project);

packages/flutter_tools/test/commands.shard/hermetic/create_usage_test.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class FakePub extends Fake implements Pub {
3636
String? flutterRootOverride,
3737
bool checkUpToDate = false,
3838
bool shouldSkipThirdPartyGenerator = true,
39-
PubOutputMode outputMode = PubOutputMode.standard,
39+
bool printProgress = true,
4040
}) async {
4141
project.directory.childFile('.packages').createSync();
4242
if (offline == true) {

packages/flutter_tools/test/commands.shard/hermetic/drive_test.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -486,7 +486,7 @@ class FakePub extends Fake implements Pub {
486486
String? flutterRootOverride,
487487
bool checkUpToDate = false,
488488
bool shouldSkipThirdPartyGenerator = true,
489-
PubOutputMode outputMode = PubOutputMode.standard,
489+
bool printProgress = true,
490490
}) async { }
491491
}
492492

packages/flutter_tools/test/commands.shard/hermetic/pub_get_test.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ class FakePub extends Fake implements Pub {
190190
required String command,
191191
bool touchesPackageConfig = false,
192192
bool generateSyntheticPackage = false,
193-
PubOutputMode outputMode = PubOutputMode.standard,
193+
bool printProgress = true,
194194
}) async {
195195
if (project != null) {
196196
fileSystem.directory(project.directory)

packages/flutter_tools/test/commands.shard/hermetic/update_packages_test.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ class FakePub extends Fake implements Pub {
282282
String? flutterRootOverride,
283283
bool checkUpToDate = false,
284284
bool shouldSkipThirdPartyGenerator = true,
285-
PubOutputMode outputMode = PubOutputMode.standard,
285+
bool printProgress = true,
286286
}) async {
287287
pubGetDirectories.add(project.directory.path);
288288
project.directory.childFile('pubspec.lock')

packages/flutter_tools/test/src/throwing_pub.dart

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class ThrowingPub implements Pub {
2929
String? flutterRootOverride,
3030
bool checkUpToDate = false,
3131
bool shouldSkipThirdPartyGenerator = true,
32-
PubOutputMode outputMode = PubOutputMode.standard,
32+
bool printProgress = true,
3333
}) {
3434
throw UnsupportedError('Attempted to invoke pub during test.');
3535
}
@@ -42,7 +42,7 @@ class ThrowingPub implements Pub {
4242
required String command,
4343
bool touchesPackageConfig = false,
4444
bool generateSyntheticPackage = false,
45-
PubOutputMode outputMode = PubOutputMode.standard,
45+
bool printProgress = true,
4646
}) {
4747
throw UnsupportedError('Attempted to invoke pub during test.');
4848
}

0 commit comments

Comments
 (0)