File tree Expand file tree Collapse file tree 4 files changed +21
-4
lines changed
Expand file tree Collapse file tree 4 files changed +21
-4
lines changed Original file line number Diff line number Diff line change @@ -10,11 +10,13 @@ var postcss = require('gulp-postcss')
1010var gulp = require('gulp')
1111var autoprefixer = require('autoprefixer')
1212var mqpacker = require('css-mqpacker')
13+ var csswring = require('csswring')
1314
1415gulp.task('css', function () {
1516 var processors = [
1617 autoprefixer('last 1 version').postcss
1718 , mqpacker.processor
19+ , csswring.postcss
1820 ]
1921 return gulp.src('./src/*.css')
2022 .pipe(postcss(processors))
Original file line number Diff line number Diff line change @@ -6,10 +6,18 @@ var gutil = require('gulp-util')
66
77module . exports = function ( processors , options ) {
88
9+ if ( ! Array . isArray ( processors ) ) {
10+ throw new gutil . PluginError ( 'gulp-postcss' , 'Please provide array of postcss processors!' )
11+ }
12+
913 return through . obj ( transform )
1014
1115 function transform ( file , encoding , cb ) {
1216
17+ if ( file . isStream ( ) ) {
18+ return cb ( new gutil . PluginError ( 'gulp-postcss' , 'Streams are not supported!' ) )
19+ }
20+
1321 // Source map is inline by default
1422 var opts = { map : 'inline' }
1523 var processor = postcss ( )
@@ -31,14 +39,13 @@ module.exports = function (processors, options) {
3139 opts . from = file . path
3240 }
3341
34- processors . forEach ( processor . use . bind ( processor ) )
35-
3642 // Generate separate source map for gulp-sourcemap
3743 if ( file . sourceMap ) {
3844 opts . map = true
3945 }
4046
4147 try {
48+ processors . forEach ( processor . use . bind ( processor ) )
4249 result = processor . process ( file . contents . toString ( 'utf8' ) , opts )
4350 } catch ( err ) {
4451 return cb ( new gutil . PluginError ( 'gulp-postcss' , err ) )
Original file line number Diff line number Diff line change 11{
22 "name" : " gulp-postcss" ,
3- "version" : " 0 .0.2 " ,
3+ "version" : " 1 .0.0 " ,
44 "description" : " PostCSS gulp plugin" ,
55 "main" : " index.js" ,
66 "scripts" : {
1111 "url" : " https://github.com/w0rm/gulp-postcss.git"
1212 },
1313 "keywords" : [
14- " gulp " ,
14+ " gulpplugin " ,
1515 " postcss" ,
1616 " css"
1717 ],
Original file line number Diff line number Diff line change @@ -46,6 +46,14 @@ it('should correctly wrap postcss errors', function (cb) {
4646} )
4747
4848
49+ it ( 'should throw error if processors are not provided' , function ( cb ) {
50+ assert . throws ( function ( ) { postcss ( ) } , gutil . PluginError )
51+ assert . throws ( function ( ) { postcss ( '' ) } , gutil . PluginError )
52+ assert . throws ( function ( ) { postcss ( { } ) } , gutil . PluginError )
53+ cb ( )
54+ } )
55+
56+
4957function doubler ( css ) {
5058 css . eachDecl ( function ( decl ) {
5159 decl . parent . prepend ( decl . clone ( ) )
You can’t perform that action at this time.
0 commit comments