@@ -24,8 +24,7 @@ main([List<String> args]) => grind(args);
2424findTransformers () 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' )
7877checkChangelogHasVersion () 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
166160validateSdkDocs () {
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' )
304293updateTestPackageDocs () {
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