keep recursing past directories with pubspec.yaml when gathering packages (#13573)

This commit is contained in:
amirh 2017-12-15 12:21:03 -08:00 committed by GitHub
parent 6728d4845d
commit 05dba60c63
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 38 additions and 4 deletions

View file

@ -361,15 +361,18 @@ class FlutterCommandRunner extends CommandRunner<Null> {
if (fs.isFileSync(fs.path.join(rootPath, '.dartignore')))
return <String>[];
if (fs.isFileSync(fs.path.join(rootPath, 'pubspec.yaml')))
return <String>[rootPath];
return fs.directory(rootPath)
final List<String> projectPaths = fs.directory(rootPath)
.listSync(followLinks: false)
.expand((FileSystemEntity entity) {
return entity is Directory ? _gatherProjectPaths(entity.path) : <String>[];
})
.toList();
if (fs.isFileSync(fs.path.join(rootPath, 'pubspec.yaml')))
projectPaths.add(rootPath);
return projectPaths;
}
void _checkFlutterCopy() {

View file

@ -18,7 +18,7 @@ dependencies:
intl: 0.15.2
json_rpc_2: 2.0.4
json_schema: 1.0.6
linter: 0.1.40
linter: 0.1.41
meta: 1.1.1
mustache: 1.0.0
package_config: 1.0.3

View file

@ -2,6 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'package:file/memory.dart';
import 'package:flutter_tools/src/base/file_system.dart';
import 'package:flutter_tools/src/runner/flutter_command_runner.dart';
import 'package:flutter_tools/src/cache.dart';
import 'package:flutter_tools/src/version.dart';
import 'package:mockito/mockito.dart';
import 'package:test/test.dart';
@ -25,4 +29,31 @@ void main() {
expect(versionChecked, isTrue);
});
});
MemoryFileSystem fs;
setUp(() {
fs = new MemoryFileSystem();
});
testUsingContext('getRepoPackages', () {
final FlutterCommandRunner runner = new FlutterCommandRunner();
final String root = fs.path.absolute(Cache.flutterRoot);
fs.directory(fs.path.join(root, 'examples'))
.createSync(recursive: true);
fs.directory(fs.path.join(root, 'packages'))
.createSync(recursive: true);
fs.directory(fs.path.join(root, 'dev', 'tools', 'aatool'))
.createSync(recursive: true);
fs.file(fs.path.join(root, 'dev', 'tools', 'pubspec.yaml')).createSync();
fs.file(fs.path.join(root, 'dev', 'tools', 'aatool', 'pubspec.yaml')).createSync();
final List<String> packagePaths = runner.getRepoPackages()
.map((Directory d) => d.path).toList();
expect(packagePaths, <String>[
fs.directory(fs.path.join(root, 'dev', 'tools', 'aatool')).path,
fs.directory(fs.path.join(root, 'dev', 'tools')).path,
]);
}, overrides: <Type, Generator>{ FileSystem: () => fs } );
}