mirror of
https://github.com/flutter/flutter.git
synced 2025-06-03 00:51:18 +00:00
run pub for analyze and test (#3310)
* run pub for analyze and test * don't run pub when doing repo analysis * move logic for when to run pub into the commands * re-write ternary expression
This commit is contained in:
parent
ec85af59b4
commit
b172dd5a1a
@ -112,6 +112,7 @@ class AnalyzeCommand extends FlutterCommand {
|
|||||||
argParser.addFlag('preamble', help: 'Display the number of files that will be analyzed.', defaultsTo: true);
|
argParser.addFlag('preamble', help: 'Display the number of files that will be analyzed.', defaultsTo: true);
|
||||||
argParser.addFlag('congratulate', help: 'Show output even when there are no errors, warnings, hints, or lints.', defaultsTo: true);
|
argParser.addFlag('congratulate', help: 'Show output even when there are no errors, warnings, hints, or lints.', defaultsTo: true);
|
||||||
argParser.addFlag('watch', help: 'Run analysis continuously, watching the filesystem for changes.', negatable: false);
|
argParser.addFlag('watch', help: 'Run analysis continuously, watching the filesystem for changes.', negatable: false);
|
||||||
|
usesPubOption();
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -120,6 +121,19 @@ class AnalyzeCommand extends FlutterCommand {
|
|||||||
@override
|
@override
|
||||||
String get description => 'Analyze the project\'s Dart code.';
|
String get description => 'Analyze the project\'s Dart code.';
|
||||||
|
|
||||||
|
@override
|
||||||
|
bool get shouldRunPub {
|
||||||
|
// If they're not analyzing the current project.
|
||||||
|
if (!argResults['current-package'])
|
||||||
|
return false;
|
||||||
|
|
||||||
|
// Or we're not in a project directory.
|
||||||
|
if (!new File('pubspec.yaml').existsSync())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return super.shouldRunPub;
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
bool get requiresProjectRoot => false;
|
bool get requiresProjectRoot => false;
|
||||||
|
|
||||||
|
@ -22,6 +22,7 @@ class TestCommand extends FlutterCommand {
|
|||||||
help: 'Run tests from the \'flutter\' package in the Flutter repository instead of the current directory.',
|
help: 'Run tests from the \'flutter\' package in the Flutter repository instead of the current directory.',
|
||||||
defaultsTo: false
|
defaultsTo: false
|
||||||
);
|
);
|
||||||
|
usesPubOption();
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -30,6 +31,9 @@ class TestCommand extends FlutterCommand {
|
|||||||
@override
|
@override
|
||||||
String get description => 'Run Flutter unit tests for the current project (Linux only).';
|
String get description => 'Run Flutter unit tests for the current project (Linux only).';
|
||||||
|
|
||||||
|
@override
|
||||||
|
bool get shouldRunPub => !argResults['flutter-repo'] && super.shouldRunPub;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
bool get requiresProjectRoot => false;
|
bool get requiresProjectRoot => false;
|
||||||
|
|
||||||
|
@ -41,6 +41,8 @@ abstract class FlutterCommand extends Command {
|
|||||||
|
|
||||||
bool _usesPubOption = false;
|
bool _usesPubOption = false;
|
||||||
|
|
||||||
|
bool get shouldRunPub => _usesPubOption && argResults['pub'];
|
||||||
|
|
||||||
List<BuildConfiguration> get buildConfigurations => runner.buildConfigurations;
|
List<BuildConfiguration> get buildConfigurations => runner.buildConfigurations;
|
||||||
|
|
||||||
void usesTargetOption() {
|
void usesTargetOption() {
|
||||||
@ -120,7 +122,7 @@ abstract class FlutterCommand extends Command {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_usesPubOption && argResults['pub']) {
|
if (shouldRunPub) {
|
||||||
int exitCode = await pubGet();
|
int exitCode = await pubGet();
|
||||||
if (exitCode != 0)
|
if (exitCode != 0)
|
||||||
return exitCode;
|
return exitCode;
|
||||||
|
Loading…
Reference in New Issue
Block a user