Skip to content

Commit d2716d7

Browse files
committed
Fix up package_builder and add clean target so I notice in the future.
1 parent 3c60e12 commit d2716d7

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

lib/src/model/package_builder.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ class PackageBuilder {
4141
Future<PackageGraph> buildPackageGraph() async {
4242
if (!config.sdkDocs) {
4343
if (config.topLevelPackageMeta.needsPubGet &&
44+
config.topLevelPackageMeta.requiresFlutter &&
4445
config.flutterRoot == null) {
4546
throw DartdocOptionError(
4647
'Top level package requires Flutter but FLUTTER_ROOT environment variable not set');

tool/grind.dart

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -527,6 +527,7 @@ Future<List<Map>> _buildTestPackageDocs(
527527
}
528528

529529
@Task('Build generated test package docs (with inherited docs and source code)')
530+
@Depends(clean)
530531
Future<void> buildTestPackageDocs() async {
531532
await _buildTestPackageDocs(
532533
testPackageDocsDir.absolute.path, Future.value(Directory.current.path));
@@ -903,23 +904,44 @@ Future<void> tryPublish() async {
903904
}
904905

905906
@Task('Run a smoke test, only')
907+
@Depends(clean)
906908
Future<void> smokeTest() async {
907909
await testDart2(smokeTestFiles);
908910
await testFutures.wait();
909911
}
910912

911913
@Task('Run non-smoke tests, only')
914+
@Depends(clean)
912915
Future<void> longTest() async {
913916
await testDart2(testFiles);
914917
await testFutures.wait();
915918
}
916919

917920
@Task('Run all the tests.')
921+
@Depends(clean)
918922
Future<void> test() async {
919923
await testDart2(smokeTestFiles.followedBy(testFiles));
920924
await testFutures.wait();
921925
}
922926

927+
@Task('Clean up pub data from test directories')
928+
Future<void> clean() async {
929+
var toDelete = nonRootPubData;
930+
toDelete.forEach((e) => e.deleteSync(recursive: true));
931+
}
932+
933+
Iterable<FileSystemEntity> get nonRootPubData {
934+
// This involves deleting things, so be careful.
935+
if (!File(path.join('tool', 'grind.dart')).existsSync()) {
936+
throw FileSystemException('wrong CWD, run from root of dartdoc package');
937+
}
938+
return Directory('.')
939+
.listSync(recursive: true)
940+
.where((e) => path.dirname(e.path) != '.')
941+
.where((e) => <String>['.dart_tool', '.packages', 'pubspec.lock']
942+
.contains(path.basename(e.path)));
943+
}
944+
923945
List<File> get smokeTestFiles => Directory('test')
924946
.listSync(recursive: true)
925947
.whereType<File>()
@@ -1017,6 +1039,7 @@ Future<WarningsCollection> _buildDartdocFlutterPluginDocs() async {
10171039
}
10181040

10191041
@Task('Build docs for a package that requires flutter with remote linking')
1042+
@Depends(clean)
10201043
Future<void> buildDartdocFlutterPluginDocs() async {
10211044
await _buildDartdocFlutterPluginDocs();
10221045
}

0 commit comments

Comments
 (0)