File tree Expand file tree Collapse file tree 3 files changed +25
-3
lines changed Expand file tree Collapse file tree 3 files changed +25
-3
lines changed Original file line number Diff line number Diff line change @@ -52,11 +52,13 @@ var cssLintPlugin = function(options) {
5252 if ( file . isNull ( ) ) return cb ( null , file ) ; // pass along
5353 if ( file . isStream ( ) ) return cb ( new error ( 'gulp-csslint: Streaming not supported' ) ) ;
5454
55+ var content = file . contents . toString ( 'utf8' ) ;
56+
57+ if ( ! content ) return cb ( null , file ) ; // pass along
58+
5559 rcLoader . for ( file . path , function ( err , opts ) {
5660 if ( err ) return cb ( err ) ;
5761
58- var str = file . contents . toString ( 'utf8' ) ;
59-
6062 for ( var rule in opts ) {
6163 if ( ! opts [ rule ] ) {
6264 // Remove rules that are turned off
@@ -67,7 +69,7 @@ var cssLintPlugin = function(options) {
6769 }
6870 }
6971
70- var report = csslint . verify ( str , ruleset ) ;
72+ var report = csslint . verify ( content , ruleset ) ;
7173
7274 // send status down-stream
7375 file . csslint = formatOutput ( report , file , ruleset ) ;
Original file line number Diff line number Diff line change @@ -223,5 +223,25 @@ describe('gulp-csslint', function() {
223223 stream . write ( file ) ;
224224 stream . end ( ) ;
225225 } ) ;
226+
227+ it ( 'should not fail on empty files' , function ( done ) {
228+ var a = 0 ;
229+
230+ var file = getFile ( 'fixtures/empty.css' ) ;
231+
232+ var stream = cssLintPlugin ( ) ;
233+
234+ stream . on ( 'data' , function ( newFile ) {
235+ ++ a ;
236+ should . not . exist ( newFile . csslint ) ;
237+ } ) ;
238+ stream . once ( 'end' , function ( ) {
239+ a . should . equal ( 1 ) ;
240+ done ( ) ;
241+ } ) ;
242+
243+ stream . write ( file ) ;
244+ stream . end ( ) ;
245+ } ) ;
226246 } ) ;
227247} ) ;
You can’t perform that action at this time.
0 commit comments