Skip to content

Commit f2dc5b2

Browse files
committed
grunt.js: Improved error handling and verbose and logging of xmllint task
1 parent cc32790 commit f2dc5b2

1 file changed

Lines changed: 18 additions & 6 deletions

File tree

grunt.js

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,31 @@ grunt.initConfig({
1313
});
1414

1515
grunt.registerTask( "xmllint", function() {
16-
var taskDone = this.async();
17-
grunt.utils.async.forEachSeries( entryFiles, function( file, done ) {
16+
var task = this,
17+
taskDone = task.async();
18+
grunt.utils.async.forEachSeries( entryFiles, function( fileName, fileDone ) {
19+
grunt.verbose.write( "Linting " + fileName + "..." );
1820
grunt.utils.spawn({
1921
cmd: "xmllint",
20-
args: [ "--noout", file ]
22+
args: [ "--noout", fileName ]
2123
}, function( err, result ) {
2224
if ( err ) {
25+
grunt.verbose.error();
2326
grunt.log.error( err );
24-
done();
27+
fileDone();
2528
return;
2629
}
27-
done();
28-
}, taskDone);
30+
grunt.verbose.ok();
31+
fileDone();
32+
});
33+
}, function() {
34+
if ( task.errorCount ) {
35+
grunt.warn( "Task \"xmllint\" failed." );
36+
taskDone();
37+
return;
38+
}
39+
grunt.log.writeln( "Lint free." );
40+
taskDone();
2941
});
3042
});
3143

0 commit comments

Comments
 (0)