File tree Expand file tree Collapse file tree 3 files changed +45
-5
lines changed Expand file tree Collapse file tree 3 files changed +45
-5
lines changed Original file line number Diff line number Diff line change @@ -93,15 +93,15 @@ cssLintPlugin.reporter = function(customReporter) {
9393 }
9494
9595 if ( builtInReporter ) {
96- output = reporter . startFormat ( ) ;
96+ output = [ reporter . startFormat ( ) ] ;
9797 }
9898
9999 return through . obj (
100100 function ( file , enc , cb ) {
101101 // Only report if CSSLint was ran and errors were found
102102 if ( file . csslint && ! file . csslint . success ) {
103103 if ( builtInReporter ) {
104- output += reporter . formatResults ( file . csslint . originalReport , file . path ) ;
104+ output . push ( reporter . formatResults ( file . csslint . originalReport , file . path ) ) ;
105105 }
106106 else {
107107 reporter ( file ) ;
@@ -111,10 +111,14 @@ cssLintPlugin.reporter = function(customReporter) {
111111 return cb ( null , file ) ;
112112 } ,
113113 function ( cb ) {
114+ var report ;
115+
114116 if ( builtInReporter ) {
115- output += reporter . endFormat ( ) ;
117+ output . push ( reporter . endFormat ( ) ) ;
118+ report = output . join ( '' ) ;
116119
117- gutil . log ( output ) ;
120+ // Only print report if the report is not empty
121+ report && gutil . log ( report ) ;
118122 }
119123
120124 return cb ( ) ;
Original file line number Diff line number Diff line change 1- .foo {
1+ .is- foo {
22 color : red;
33}
Original file line number Diff line number Diff line change @@ -273,7 +273,9 @@ describe('gulp-csslint', function() {
273273 stream . write ( file ) ;
274274 stream . end ( ) ;
275275 } ) ;
276+ } ) ;
276277
278+ describe ( 'cssLintPlugin.reporter()' , function ( ) {
277279 it ( 'should support built-in CSSLint formatters' , sinon . test ( function ( done ) {
278280 var a = 0 ;
279281
@@ -307,5 +309,39 @@ describe('gulp-csslint', function() {
307309 lintStream . write ( file ) ;
308310 lintStream . end ( ) ;
309311 } ) ) ;
312+
313+ it ( 'should not print empty output by built-in CSSLint formatters' , sinon . test ( function ( done ) {
314+ var a = 0 ;
315+
316+ var file = getFile ( 'fixtures/validCSS.css' ) ;
317+
318+ var lintStream = cssLintPlugin ( ) ;
319+ var reporterStream = cssLintPlugin . reporter ( 'text' ) ;
320+
321+ sinon . stub ( gutil , 'log' ) ;
322+
323+ reporterStream . on ( 'data' , function ( ) {
324+ ++ a ;
325+ } ) ;
326+ lintStream . on ( 'data' , function ( newFile ) {
327+ should . exist ( newFile . csslint . success ) ;
328+ newFile . csslint . success . should . equal ( true ) ;
329+ reporterStream . write ( newFile ) ;
330+ } ) ;
331+ lintStream . once ( 'end' , function ( ) {
332+ reporterStream . end ( ) ;
333+ } ) ;
334+
335+ reporterStream . once ( 'end' , function ( ) {
336+ a . should . equal ( 1 ) ;
337+ sinon . assert . callCount ( gutil . log , 0 ) ;
338+
339+ gutil . log . restore ( ) ;
340+ done ( ) ;
341+ } ) ;
342+
343+ lintStream . write ( file ) ;
344+ lintStream . end ( ) ;
345+ } ) ) ;
310346 } ) ;
311347} ) ;
You can’t perform that action at this time.
0 commit comments