@@ -11,6 +11,7 @@ var doNothing = function() {};
1111 * @name Comb
1212 */
1313var Comb = function ( ) {
14+ this . SUPPORTED_SYNTAXES = [ 'css' , 'scss' , 'less' ] ;
1415 this . _options = [
1516 'remove-empty-rulesets' ,
1617 'always-semicolon' ,
@@ -130,8 +131,7 @@ Comb.prototype = {
130131 */
131132 processFile : function ( path ) {
132133 var _this = this ;
133- // TODO: Move extension check into `_shouldProcess` method
134- if ( this . _shouldProcess ( path ) && path . match ( / \. [ c s s , s c s s ] $ / ) ) {
134+ if ( this . _shouldProcessFile ( path ) ) {
135135 return vfs . read ( path , 'utf8' ) . then ( function ( data ) {
136136 var syntax = path . split ( '.' ) . pop ( ) ;
137137 var processedData = _this . processString ( data , syntax , path ) ;
@@ -168,17 +168,15 @@ Comb.prototype = {
168168 return vfs . listDir ( path ) . then ( function ( filenames ) {
169169 return vow . all ( filenames . map ( function ( filename ) {
170170 var fullname = path + '/' + filename ;
171- if ( _this . _shouldProcess ( fullname ) ) {
172- return vfs . stat ( fullname ) . then ( function ( stat ) {
173- if ( stat . isDirectory ( ) ) {
174- return _this . processDirectory ( fullname ) ;
175- } else if ( fullname . match ( / \. c s s $ / ) ) {
176- return vow . when ( _this . processFile ( fullname ) ) . then ( function ( errors ) {
177- if ( errors ) return errors ;
178- } ) ;
179- }
180- } ) ;
181- }
171+ return vfs . stat ( fullname ) . then ( function ( stat ) {
172+ if ( stat . isDirectory ( ) ) {
173+ return _this . _shouldProcess ( fullname ) && _this . processDirectory ( fullname ) ;
174+ } else {
175+ return vow . when ( _this . processFile ( fullname ) ) . then ( function ( errors ) {
176+ if ( errors ) return errors ;
177+ } ) ;
178+ }
179+ } ) ;
182180 } ) ) . then ( function ( results ) {
183181 return [ ] . concat . apply ( [ ] , results ) ;
184182 } ) ;
@@ -223,8 +221,24 @@ Comb.prototype = {
223221 if ( exclude [ i ] . match ( path ) ) return false ;
224222 }
225223 return true ;
226- }
224+ } ,
225+
226+ /**
227+ * Returns true if specified path is not in excluded list and has one of
228+ * acceptable extensions.
229+ *
230+ * @returns {Boolean }
231+ */
232+ _shouldProcessFile : function ( path ) {
233+ // Get file's extension:
234+ var syntax = path . split ( '.' ) . pop ( ) ;
235+ // Check if syntax is supported. If not, ignore the file:
236+ if ( this . SUPPORTED_SYNTAXES . indexOf ( syntax ) < 0 ) {
237+ return false ;
238+ }
227239
240+ return this . _shouldProcess ( path ) ;
241+ }
228242} ;
229243
230244module . exports = Comb ;
0 commit comments