@@ -72,15 +72,59 @@ module.exports = function (grunt) {
7272 }
7373 } ) . forEach ( function ( src ) {
7474
75- // Get CSS from a source file:
76- var css = grunt . file . read ( src ) ;
77-
78- // Comb it:
79- grunt . log . ok ( 'Sorting file "' + src + '"...' ) ;
80- var syntax = src . split ( '.' ) . pop ( ) ;
81- var combed = comb . processString ( css , { syntax : syntax } ) ;
82- grunt . file . write ( f . dest , combed ) ;
75+ // Placeholder for our css content
76+ var css ;
77+
78+ if ( shouldProcess ( src , config ) ) {
79+
80+ // Get CSS from a source file:
81+ css = grunt . file . read ( src ) ;
82+
83+ // Comb it:
84+ grunt . log . ok ( 'Sorting file "' + src + '"...' ) ;
85+ var syntax = src . split ( '.' ) . pop ( ) ;
86+ var combed = comb . processString ( css , { syntax : syntax } ) ;
87+ grunt . file . write ( f . dest , combed ) ;
88+ } else {
89+ grunt . log . ok ( 'Skipping file "' + src + '" because of exclude.' ) ;
90+ grunt . file . copy ( src , f . dest ) ;
91+ }
8392 } ) ;
8493 } ) ;
8594 } ) ;
95+
96+ function shouldProcess ( src , config ) {
97+ var excludes = zip (
98+ ( config . exclude || [ ] ) . map ( function ( pattern ) {
99+ return grunt . file . expand ( pattern ) ;
100+ } )
101+ ) ;
102+ var ok = true ;
103+
104+ if ( excludes ) {
105+ var found = false ;
106+ src = src . replace ( / ^ \. \/ / , '' ) ;
107+ for ( var i = 0 , excludeLength = excludes . length ; i < excludeLength && ! found ; i ++ ) {
108+ if ( excludes [ i ] . match ( src ) ) {
109+ found = true ;
110+ }
111+ }
112+
113+ ok = ok && ! found ;
114+ }
115+
116+ return ok ;
117+ }
118+
119+ function zip ( arrays ) {
120+ var returnArray = [ ] ;
121+
122+ arrays . forEach ( function ( value ) {
123+ value . forEach ( function ( item ) {
124+ returnArray . push ( item ) ;
125+ } ) ;
126+ } ) ;
127+
128+ return returnArray ;
129+ }
86130} ;
0 commit comments