Skip to content
This repository has been archived by the owner on Dec 29, 2020. It is now read-only.

Handle jscs errors #16

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions tasks/jscs.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ module.exports = function( grunt ) {
};

grunt.registerMultiTask( "jscs", "JavaScript Code Style checker", function() {
var errorCount, i;
var errorCount, completed;
var jscs = new Checker();
var options = this.options( defaults );
var cfgPath = options.config;
Expand All @@ -32,7 +32,8 @@ module.exports = function( grunt ) {
jscs.registerDefaultRules();
jscs.configure( require( cfgPath ) );

errorCount = i = 0;
errorCount = 0;
completed = 0;

if ( junitXML ) {
junitXML.ele( "testsuite", {
Expand All @@ -42,10 +43,10 @@ module.exports = function( grunt ) {
}

function update() {
i++;
completed++;

// Does all promises have been run?
if ( i === files.length ) {
if ( completed === files.length ) {
if ( junitXML ) {
junitXML.att( "tests", files.length );
junitXML.att( "errors", errorCount );
Expand All @@ -54,7 +55,7 @@ module.exports = function( grunt ) {
}

if ( errorCount > 0 ) {
grunt.log.ok( errorCount + " code style errors found!" );
grunt.log.error( errorCount + " code style errors found!" );

done( false );
} else {
Expand Down Expand Up @@ -91,7 +92,9 @@ module.exports = function( grunt ) {
}

update();
});
}, function( error ) {
grunt.fail.warn(error);
});
});
});
};
};
2 changes: 1 addition & 1 deletion test/expectations/all
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
 1 |while (false);
--------^
 2 |
>> 1 code style errors found!
>> 1 code style errors found!
Warning: Task "jscs:fail" failed. Use --force to continue.

Aborted due to warnings.
2 changes: 1 addition & 1 deletion test/expectations/config
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
 1 |while (false);
--------^
 2 |
>> 1 code style errors found!
>> 1 code style errors found!
Warning: Task "jscs:config" failed. Use --force to continue.

Aborted due to warnings.
2 changes: 1 addition & 1 deletion test/expectations/fail
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
 1 |while (false);
--------^
 2 |
>> 1 code style errors found!
>> 1 code style errors found!
Warning: Task "jscs:fail" failed. Use --force to continue.

Aborted due to warnings.