Skip to content

Commit 5d1531c

Browse files
authored
Merge pull request #1180 from dart-lang/maintain_grind_script
some maintainence on the grind script
2 parents 5fbd9c7 + c0145d5 commit 5d1531c

File tree

2 files changed

+8
-27
lines changed

2 files changed

+8
-27
lines changed

tool/doc_packages.dart

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@ import 'package:http/http.dart' as http;
1414
import 'package:pub_semver/pub_semver.dart';
1515
import 'package:yaml/yaml.dart';
1616

17-
// TODO: Use isolates; Platform.numberOfProcessors.
18-
1917
const String _rootDir = 'pub.dartlang.org';
2018

2119
/// To use:

tool/grind.dart

Lines changed: 8 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,7 @@ main([List<String> args]) => grind(args);
2424
findTransformers() async {
2525
var dotPackages = new File('.packages');
2626
if (!dotPackages.existsSync()) {
27-
print('No .packages file found in ${Directory.current}');
28-
exit(1);
27+
fail('No .packages file found in ${Directory.current}');
2928
}
3029

3130
var foundAnyTransformers = false;
@@ -39,16 +38,16 @@ findTransformers() async {
3938
if (pubspec.existsSync()) {
4039
var yamlDoc = yaml.loadYaml(pubspec.readAsStringSync());
4140
if (yamlDoc['transformers'] != null) {
42-
print('${mapping.first} has transformers!');
41+
log('${mapping.first} has transformers!');
4342
foundAnyTransformers = true;
4443
}
4544
} else {
46-
print('No pubspec found for ${mapping.first}, tried ${pubspec}');
45+
log('No pubspec found for ${mapping.first}, tried ${pubspec}');
4746
}
4847
});
4948

5049
if (!foundAnyTransformers) {
51-
print('No transformers found');
50+
log('No transformers found');
5251
}
5352
}
5453

@@ -76,20 +75,15 @@ checkVersionMatches() async {
7675

7776
@Task('Checks that CHANGELOG mentions current version')
7877
checkChangelogHasVersion() async {
79-
// TODO: use fail() when
80-
// https://github.com/google/grinder.dart/issues/288 lands
81-
8278
var changelog = new File('CHANGELOG.md');
8379
if (!changelog.existsSync()) {
84-
print('ERROR: No CHANGELOG.md found in ${Directory.current}');
85-
exit(1);
80+
fail('ERROR: No CHANGELOG.md found in ${Directory.current}');
8681
}
8782

8883
Pubspec pubspec = await Pubspec.load();
8984

9085
if (!changelog.readAsLinesSync().contains('## ${pubspec.version}')) {
91-
print('ERROR: CHANGELOG.md does not mention version ${pubspec.version}');
92-
exit(1);
86+
fail('ERROR: CHANGELOG.md does not mention version ${pubspec.version}');
9387
}
9488
}
9589

@@ -164,7 +158,6 @@ Future buildSdkDocs() async {
164158
// if I run grind build-sdk-docs manually.
165159
// See https://github.com/google/grinder.dart/issues/291
166160
validateSdkDocs() {
167-
// TODO(keertip): change number to 17 once 1.13 is stable
168161
const expectedLibCount = 18;
169162
var indexHtml = joinFile(docsDir, ['index.html']);
170163
if (!indexHtml.existsSync()) {
@@ -258,12 +251,11 @@ _doCheck(String origin, Set<String> visited, String pathToCheck, bool error,
258251
var fullPath = path.normalize("$origin$pathToCheck");
259252
if (visited.contains(fullPath)) return;
260253
visited.add(fullPath);
261-
//print("Visiting $fullPath");
262254

263255
File file = new File("$fullPath");
264256
if (!file.existsSync()) {
265257
error = true;
266-
print(' * Not found: $fullPath from $source');
258+
log(' * Not found: $fullPath from $source');
267259
return;
268260
}
269261
Document doc = parse(file.readAsStringSync());
@@ -272,17 +264,14 @@ _doCheck(String origin, Set<String> visited, String pathToCheck, bool error,
272264
if (base != null) {
273265
baseHref = base.attributes['href'];
274266
}
275-
//print(" Base is $baseHref");
276267
List<Element> links = doc.querySelectorAll('a');
277268
links
278269
.map((link) => link.attributes['href'])
279270
.where((href) => href != null)
280271
.forEach((href) {
281272
if (!href.startsWith('http') && !href.contains('#')) {
282-
//print(" Found link: $href");
283273
var full = '${path.dirname(pathToCheck)}/$baseHref/$href';
284274
var normalized = path.normalize(full);
285-
//print(" => $full\n => $normalized");
286275
_doCheck(origin, visited, normalized, error, pathToCheck);
287276
}
288277
});
@@ -303,13 +292,7 @@ checkSdkLinks() {
303292
@Task('update test_package_docs')
304293
updateTestPackageDocs() {
305294
var options = new RunOptions(workingDirectory: 'testing/test_package');
306-
307-
var dir = new Directory('test_package_docs');
308-
309-
if (dir.existsSync()) {
310-
dir.deleteSync(recursive: true);
311-
}
312-
295+
delete(getDir('test_package_docs'));
313296
Dart.run('../../bin/dartdoc.dart',
314297
arguments: ['--no-include-source', '--output', '../test_package_docs'],
315298
runOptions: options);

0 commit comments

Comments
 (0)