66 * Licensed under the MIT license.
77 */
88'use strict' ;
9+ module . exports = function ( grunt ) {
910
10- module . exports = function ( grunt ) {
11-
12- grunt . registerMultiTask ( 'csscomb' , 'Sorting CSS properties in specific order.' , function ( ) {
13-
11+ grunt . registerMultiTask ( 'csscomb' , 'Sorting CSS properties in specific order.' , function ( ) {
1412 var fs = require ( 'fs' ) ,
15- path = require ( 'path' ) ,
16- exec = require ( 'child_process' ) . exec ;
17-
13+ path = require ( 'path' ) ,
14+ exec = require ( 'child_process' ) . exec ;
1815 var done = this . async ( ) ,
19- realPath = path . dirname ( fs . realpathSync ( __filename ) ) ,
20- cssComb = 'php ' + realPath + '/lib/csscomb.php' ,
21- fileSrc = '' ,
22- fileDest = '' ,
23- fileSort = '' ,
24- options = this . options ( {
25- sortOrder : null
26- } ) ;
27-
16+ realPath = path . dirname ( fs . realpathSync ( __filename ) ) ,
17+ cssComb = 'php ' + realPath + '/lib/csscomb.php' ,
18+ fileSrc = '' ,
19+ fileDest = '' ,
20+ fileSort = '' ,
21+ options = this . options ( {
22+ sortOrder : null
23+ } ) ;
2824 if ( options . sortOrder !== null ) {
2925 if ( grunt . file . exists ( options . sortOrder ) ) {
3026 fileSort = ' -s ' + options . sortOrder ;
@@ -35,40 +31,33 @@ module.exports = function (grunt) {
3531 }
3632
3733 function puts ( error , stdout , stderr ) {
38- grunt . log . ok ( stdout ) ;
3934 if ( error !== null ) {
4035 grunt . log . error ( error ) ;
41- done ( false ) ;
4236 } else {
43- done ( true ) ;
37+ grunt . log . ok ( stdout ) ;
4438 }
4539 }
4640
47- this . files . forEach ( function ( file ) {
48- fileSrc = file . src . filter ( function ( filepath ) {
41+ this . files . forEach ( function ( file ) {
42+ fileSrc = file . src . filter ( function ( filepath ) {
4943 // Remove nonexistent files (it's up to you to filter or warn here).
5044 if ( ! grunt . file . exists ( filepath ) ) {
5145 grunt . log . warn ( 'Source file "' + filepath + '" not found.' ) ;
5246 return false ;
5347 } else {
5448 return true ;
5549 }
56- } ) . map ( function ( filepath ) {
50+ } ) . map ( function ( filepath ) {
5751 return filepath ;
5852 } ) ;
59-
6053 fileSrc = ' -i ' + fileSrc ;
6154 if ( file . dest !== null ) {
6255 fileDest = ' -o ' + file . dest ;
6356 }
64-
6557 var command = cssComb + fileSort + fileSrc + fileDest ;
6658 exec ( command , puts ) ;
67-
6859 // grunt.log.writeln('`' + command + '` was initiated.');
69-
7060 } ) ;
71-
7261 } ) ;
7362
7463} ;
0 commit comments