Commit 305af8b8 authored by pq's avatar pq

Fix flutter analyze defaults when files are specified (#4091).

Disables current package and current directory analysis when files are specified.

Fixes: https://github.com/flutter/flutter/issues/4091.
parent 24dbf31a
...@@ -102,9 +102,13 @@ class AnalyzeCommand extends FlutterCommand { ...@@ -102,9 +102,13 @@ class AnalyzeCommand extends FlutterCommand {
} }
} }
bool currentDirectory = argResults['current-directory'] && dartFiles.isEmpty;
bool currentPackage = argResults['current-package'] && dartFiles.isEmpty;
bool flutterRepo = argResults['flutter-repo'];
//TODO (pq): revisit package and directory defaults //TODO (pq): revisit package and directory defaults
if (argResults['current-directory'] && !argResults['flutter-repo']) { if (currentDirectory && !flutterRepo) {
// ./*.dart // ./*.dart
Directory currentDirectory = new Directory('.'); Directory currentDirectory = new Directory('.');
bool foundOne = false; bool foundOne = false;
...@@ -118,7 +122,7 @@ class AnalyzeCommand extends FlutterCommand { ...@@ -118,7 +122,7 @@ class AnalyzeCommand extends FlutterCommand {
pubSpecDirectories.add(currentDirectory); pubSpecDirectories.add(currentDirectory);
} }
if (argResults['current-package'] && !argResults['flutter-repo']) { if (currentPackage && !flutterRepo) {
// **/.*dart // **/.*dart
Directory currentDirectory = new Directory('.'); Directory currentDirectory = new Directory('.');
_collectDartFiles(currentDirectory, dartFiles); _collectDartFiles(currentDirectory, dartFiles);
...@@ -129,7 +133,7 @@ class AnalyzeCommand extends FlutterCommand { ...@@ -129,7 +133,7 @@ class AnalyzeCommand extends FlutterCommand {
//TODO (pq): extract this regexp from the exclude in options //TODO (pq): extract this regexp from the exclude in options
RegExp stockExampleFiles = new RegExp('examples/stocks/lib/.*\.dart\$'); RegExp stockExampleFiles = new RegExp('examples/stocks/lib/.*\.dart\$');
if (argResults['flutter-repo']) { if (flutterRepo) {
for (Directory dir in runner.getRepoPackages()) { for (Directory dir in runner.getRepoPackages()) {
_collectDartFiles(dir, dartFiles, _collectDartFiles(dir, dartFiles,
exclude: (FileSystemEntity entity) => stockExampleFiles.hasMatch(entity.path)); exclude: (FileSystemEntity entity) => stockExampleFiles.hasMatch(entity.path));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment