Skip to content

Commit

Permalink
replace enum with simpler boolean
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewkolos committed Jan 11, 2023
1 parent b33c5fd commit 445dbc4
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 24 deletions.
2 changes: 1 addition & 1 deletion packages/flutter_tools/lib/src/commands/create.dart
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@ class CreateCommand extends CreateBase {
context: pubContext,
project: project,
offline: boolArgDeprecated('offline'),
outputMode: PubOutputMode.summaryOnly,
printProgress: false,
);
await project.ensureReadyForPlatformSpecificTooling(
androidPlatform: includeAndroid,
Expand Down
4 changes: 2 additions & 2 deletions packages/flutter_tools/lib/src/commands/update_packages.dart
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ class UpdatePackagesCommand extends FlutterCommand {
upgrade: doUpgrade,
offline: boolArgDeprecated('offline'),
flutterRootOverride: temporaryFlutterSdk?.path,
outputMode: PubOutputMode.none,
printProgress: false,
);

if (doUpgrade) {
Expand Down Expand Up @@ -538,7 +538,7 @@ class UpdatePackagesCommand extends FlutterCommand {
// All dependencies should already have been downloaded by the fake
// package, so the concurrent checks can all happen offline.
offline: true,
outputMode: PubOutputMode.none,
printProgress: false,
);
stopwatch.stop();
final double seconds = stopwatch.elapsedMilliseconds / 1000.0;
Expand Down
28 changes: 13 additions & 15 deletions packages/flutter_tools/lib/src/dart/pub.dart
Original file line number Diff line number Diff line change
Expand Up @@ -140,12 +140,6 @@ class PubContext {
}
}

enum PubOutputMode {
none,
standard,
summaryOnly,
}

/// A handle for interacting with the pub tool.
abstract class Pub {
/// Create a default [Pub] instance.
Expand Down Expand Up @@ -178,6 +172,10 @@ abstract class Pub {
/// If [shouldSkipThirdPartyGenerator] is true, the overall pub get will be
/// skipped if the package config file has a "generator" other than "pub".
/// Defaults to true.
///
/// If [printProgress] is true, `pub get` will inherit stdio from the current process.
/// Defaults to true.
///
/// Will also resolve dependencies in the example folder if present.
Future<void> get({
required PubContext context,
Expand All @@ -187,7 +185,7 @@ abstract class Pub {
String? flutterRootOverride,
bool checkUpToDate = false,
bool shouldSkipThirdPartyGenerator = true,
PubOutputMode outputMode = PubOutputMode.standard
bool printProgress = true,
});

/// Runs pub in 'batch' mode.
Expand Down Expand Up @@ -227,7 +225,7 @@ abstract class Pub {
required String command,
bool touchesPackageConfig = false,
bool generateSyntheticPackage = false,
PubOutputMode outputMode = PubOutputMode.standard
bool printProgress = true,
});
}

Expand Down Expand Up @@ -292,7 +290,7 @@ class _DefaultPub implements Pub {
String? flutterRootOverride,
bool checkUpToDate = false,
bool shouldSkipThirdPartyGenerator = true,
PubOutputMode outputMode = PubOutputMode.standard
bool printProgress = true,
}) async {
final String directory = project.directory.path;
final File packageConfigFile = project.packageConfigFile;
Expand Down Expand Up @@ -364,7 +362,7 @@ class _DefaultPub implements Pub {
directory: directory,
failureMessage: 'pub $command failed',
flutterRootOverride: flutterRootOverride,
outputMode: outputMode,
printProgress: printProgress,
);
await _updateVersionAndPackageConfig(project);
}
Expand All @@ -381,19 +379,19 @@ class _DefaultPub implements Pub {
Future<void> _runWithStdioInherited(
List<String> arguments, {
required String command,
required PubOutputMode outputMode,
required PubContext context,
required String directory,
String failureMessage = 'pub failed',
String? flutterRootOverride,
bool printProgress = true
}) async {
int exitCode;

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

try {
if (outputMode != PubOutputMode.none) {
if (printProgress) {
final io.Stdio? stdio = _stdio;
if (stdio == null) {
// Let pub inherit stdio and output directly to the tool's stdout and
Expand Down Expand Up @@ -564,14 +562,14 @@ class _DefaultPub implements Pub {
required String command,
bool touchesPackageConfig = false,
bool generateSyntheticPackage = false,
PubOutputMode outputMode = PubOutputMode.standard
bool printProgress = true,
}) async {
await _runWithStdioInherited(
arguments,
command: command,
directory: _fileSystem.currentDirectory.path,
context: context,
outputMode: outputMode,
printProgress: printProgress,
);
if (touchesPackageConfig && project != null) {
await _updateVersionAndPackageConfig(project);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class FakePub extends Fake implements Pub {
String? flutterRootOverride,
bool checkUpToDate = false,
bool shouldSkipThirdPartyGenerator = true,
PubOutputMode outputMode = PubOutputMode.standard,
bool printProgress = true,
}) async {
project.directory.childFile('.packages').createSync();
if (offline == true) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,7 @@ class FakePub extends Fake implements Pub {
String? flutterRootOverride,
bool checkUpToDate = false,
bool shouldSkipThirdPartyGenerator = true,
PubOutputMode outputMode = PubOutputMode.standard,
bool printProgress = true,
}) async { }
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ class FakePub extends Fake implements Pub {
required String command,
bool touchesPackageConfig = false,
bool generateSyntheticPackage = false,
PubOutputMode outputMode = PubOutputMode.standard,
bool printProgress = true,
}) async {
if (project != null) {
fileSystem.directory(project.directory)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ class FakePub extends Fake implements Pub {
String? flutterRootOverride,
bool checkUpToDate = false,
bool shouldSkipThirdPartyGenerator = true,
PubOutputMode outputMode = PubOutputMode.standard,
bool printProgress = true,
}) async {
pubGetDirectories.add(project.directory.path);
project.directory.childFile('pubspec.lock')
Expand Down
4 changes: 2 additions & 2 deletions packages/flutter_tools/test/src/throwing_pub.dart
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class ThrowingPub implements Pub {
String? flutterRootOverride,
bool checkUpToDate = false,
bool shouldSkipThirdPartyGenerator = true,
PubOutputMode outputMode = PubOutputMode.standard,
bool printProgress = true,
}) {
throw UnsupportedError('Attempted to invoke pub during test.');
}
Expand All @@ -42,7 +42,7 @@ class ThrowingPub implements Pub {
required String command,
bool touchesPackageConfig = false,
bool generateSyntheticPackage = false,
PubOutputMode outputMode = PubOutputMode.standard,
bool printProgress = true,
}) {
throw UnsupportedError('Attempted to invoke pub during test.');
}
Expand Down

0 comments on commit 445dbc4

Please sign in to comment.