File tree Expand file tree Collapse file tree 2 files changed +25
-1
lines changed
Expand file tree Collapse file tree 2 files changed +25
-1
lines changed Original file line number Diff line number Diff line change 11var through = require ( 'through2' )
22var postcss = require ( 'postcss' )
33var applySourceMap = require ( 'vinyl-sourcemaps-apply' )
4+ var gutil = require ( 'gulp-util' )
45
56
67module . exports = function ( processors , options ) {
@@ -37,7 +38,11 @@ module.exports = function (processors, options) {
3738 opts . map = true
3839 }
3940
40- result = processor . process ( file . contents . toString ( 'utf8' ) , opts )
41+ try {
42+ result = processor . process ( file . contents . toString ( 'utf8' ) , opts )
43+ } catch ( err ) {
44+ return cb ( new gutil . PluginError ( 'gulp-postcss' , err ) )
45+ }
4146
4247 file . contents = new Buffer ( result . css )
4348
Original file line number Diff line number Diff line change @@ -27,6 +27,25 @@ it('should transform css with multiple processors', function (cb) {
2727} )
2828
2929
30+ it ( 'should correctly wrap postcss errors' , function ( cb ) {
31+
32+ var stream = postcss ( [ doubler ] )
33+
34+ stream . on ( 'error' , function ( err ) {
35+ assert . ok ( err instanceof gutil . PluginError )
36+ assert . equal ( err . plugin , 'gulp-postcss' )
37+ cb ( )
38+ } )
39+
40+ stream . write ( new gutil . File ( {
41+ contents : new Buffer ( 'a {\n a b {}\n}' )
42+ } ) )
43+
44+ stream . end ( )
45+
46+ } )
47+
48+
3049function doubler ( css ) {
3150 css . eachDecl ( function ( decl ) {
3251 decl . parent . prepend ( decl . clone ( ) )
You can’t perform that action at this time.
0 commit comments