mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
Merge pull request #1286 from Hixie/better-analyze
Make 'flutter analyze' support analyzing arbitrary files
This commit is contained in:
commit
62673cf67b
@ -34,9 +34,24 @@ class AnalyzeCommand extends FlutterCommand {
|
||||
Set<String> pubSpecDirectories = new Set<String>();
|
||||
List<String> dartFiles = argResults.rest.toList();
|
||||
|
||||
bool foundAnyInCurrentDirectory = false;
|
||||
bool foundAnyInFlutterRepo = false;
|
||||
|
||||
for (String file in dartFiles) {
|
||||
// TODO(ianh): figure out how dartanalyzer decides which .packages file to use when given a random file
|
||||
pubSpecDirectories.add(path.dirname(file));
|
||||
file = path.normalize(path.absolute(file));
|
||||
String root = path.rootPrefix(file);
|
||||
while (file != root) {
|
||||
file = path.dirname(file);
|
||||
if (FileSystemEntity.isFileSync(path.join(file, 'pubspec.yaml'))) {
|
||||
pubSpecDirectories.add(file);
|
||||
if (file == path.normalize(path.absolute(ArtifactStore.flutterRoot))) {
|
||||
foundAnyInFlutterRepo = true;
|
||||
} else if (file == path.normalize(path.absolute(path.current))) {
|
||||
foundAnyInCurrentDirectory = true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (argResults['flutter-repo']) {
|
||||
@ -129,8 +144,6 @@ class AnalyzeCommand extends FlutterCommand {
|
||||
}
|
||||
}
|
||||
|
||||
bool foundAnyInCurrentDirectory = false;
|
||||
|
||||
if (argResults['current-directory']) {
|
||||
// ./*.dart
|
||||
Directory currentDirectory = new Directory('.');
|
||||
@ -204,7 +217,7 @@ class AnalyzeCommand extends FlutterCommand {
|
||||
}
|
||||
}
|
||||
if (hadInconsistentRequirements) {
|
||||
if (argResults['flutter-repo'])
|
||||
if (foundAnyInFlutterRepo)
|
||||
logging.warning('You may need to run "dart ${path.normalize(path.relative(path.join(ArtifactStore.flutterRoot, 'dev/update_packages.dart')))} --upgrade".');
|
||||
if (foundAnyInCurrentDirectory)
|
||||
logging.warning('You may need to run "pub upgrade".');
|
||||
|
||||
@ -147,9 +147,9 @@ class FlutterCommandRunner extends CommandRunner {
|
||||
Logger.root.level = Level.FINE;
|
||||
|
||||
_globalResults = globalResults;
|
||||
ArtifactStore.flutterRoot = globalResults['flutter-root'];
|
||||
ArtifactStore.flutterRoot = path.normalize(path.absolute(globalResults['flutter-root']));
|
||||
if (globalResults.wasParsed('package-root'))
|
||||
ArtifactStore.packageRoot = globalResults['package-root'];
|
||||
ArtifactStore.packageRoot = path.normalize(path.absolute(globalResults['package-root']));
|
||||
|
||||
if (globalResults['version']) {
|
||||
print(getVersion(ArtifactStore.flutterRoot));
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user