Skip to content

Commit f8d4405

Browse files
committed
Merge pull request #81 from Termina1/patch-1
Forgotten options parameter
2 parents 2d4733a + 716822c commit f8d4405

File tree

2 files changed

+33
-5
lines changed

2 files changed

+33
-5
lines changed

index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,15 +74,15 @@ module.exports = function (processors, options) {
7474
}
7575

7676
function handleError (error) {
77-
var errorOptions = { fileName: file.path }
77+
var errorOptions = { fileName: file.path, showStack: true }
7878
if (error.name === 'CssSyntaxError') {
7979
error = error.message + error.showSourceCode()
8080
errorOptions.showStack = false
8181
}
8282
// Prevent stream’s unhandled exception from
8383
// being suppressed by Promise
8484
setImmediate(function () {
85-
cb(new gutil.PluginError('gulp-postcss', error))
85+
cb(new gutil.PluginError('gulp-postcss', error, errorOptions))
8686
})
8787
}
8888

test.js

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ it('should pass file when it isNull()', function (cb) {
1818
assert.equal(data, emptyFile)
1919
cb()
2020
})
21-
21+
2222
stream.write(emptyFile)
23-
23+
2424
stream.end()
2525
})
2626

@@ -53,17 +53,45 @@ it('should correctly wrap postcss errors', function (cb) {
5353
stream.on('error', function (err) {
5454
assert.ok(err instanceof gutil.PluginError)
5555
assert.equal(err.plugin, 'gulp-postcss')
56+
assert.equal(err.showStack, false)
57+
assert.equal(err.fileName, "testpath")
5658
cb()
5759
})
5860

5961
stream.write(new gutil.File({
60-
contents: new Buffer('a {')
62+
contents: new Buffer('a {'),
63+
path: "testpath"
6164
}))
6265

6366
stream.end()
6467

6568
})
6669

70+
it('should respond with error on stream files', function (cb) {
71+
72+
var stream = postcss([ doubler ])
73+
74+
stream.on('error', function (err) {
75+
assert.ok(err instanceof gutil.PluginError)
76+
assert.equal(err.plugin, 'gulp-postcss')
77+
console.log(err)
78+
assert.equal(err.showStack, true)
79+
assert.equal(err.fileName, "testpath")
80+
cb()
81+
})
82+
83+
var streamFile = {
84+
isStream: function () { return true },
85+
isNull: function() { return false },
86+
path: "testpath"
87+
};
88+
89+
stream.write(streamFile)
90+
91+
stream.end()
92+
93+
})
94+
6795

6896
it('should throw error if processors are not provided', function (cb) {
6997
assert.throws( function () { postcss() }, gutil.PluginError )

0 commit comments

Comments
 (0)