Skip to content
Merged
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
8 changes: 5 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,13 @@ var cssLintPlugin = function(options) {
if (file.isNull()) return cb(null, file); // pass along
if (file.isStream()) return cb(new error('gulp-csslint: Streaming not supported'));

var content = file.contents.toString('utf8');

if (!content) return cb(null, file); // pass along

rcLoader.for(file.path, function(err, opts) {
if (err) return cb(err);

var str = file.contents.toString('utf8');

for (var rule in opts) {
if (!opts[rule]) {
// Remove rules that are turned off
Expand All @@ -67,7 +69,7 @@ var cssLintPlugin = function(options) {
}
}

var report = csslint.verify(str, ruleset);
var report = csslint.verify(content, ruleset);

// send status down-stream
file.csslint = formatOutput(report, file, ruleset);
Expand Down
Empty file added test/fixtures/empty.css
Empty file.
20 changes: 20 additions & 0 deletions test/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -223,5 +223,25 @@ describe('gulp-csslint', function() {
stream.write(file);
stream.end();
});

it('should not fail on empty files', function(done) {
var a = 0;

var file = getFile('fixtures/empty.css');

var stream = cssLintPlugin();

stream.on('data', function(newFile) {
++a;
should.not.exist(newFile.csslint);
});
stream.once('end', function() {
a.should.equal(1);
done();
});

stream.write(file);
stream.end();
});
});
});