Skip to content

Commit 2c0a800

Browse files
committed
Merge pull request #70 from bammoo/patch-1
Check null before process file
2 parents 8414a14 + 282444b commit 2c0a800

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

index.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ module.exports = function (processors, options) {
1515

1616
stream._transform = function (file, encoding, cb) {
1717

18+
if (file.isNull()) {
19+
return cb(null, file)
20+
}
21+
1822
if (file.isStream()) {
1923
return handleError('Streams are not supported!')
2024
}

test.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,22 @@ var postcss = require('./index')
88
var proxyquire = require('proxyquire')
99
var sinon = require('sinon')
1010

11+
it('should pass file when it isNull()', function (cb) {
12+
var stream = postcss([ doubler ])
13+
var emptyFile = {
14+
isNull: function () { return true }
15+
}
16+
17+
stream.once('data', function (data) {
18+
assert.equal(data, emptyFile)
19+
cb()
20+
})
21+
22+
stream.write(emptyFile)
23+
24+
stream.end()
25+
})
26+
1127
it('should transform css with multiple processors', function (cb) {
1228

1329
var stream = postcss(

0 commit comments

Comments
 (0)