tasks/transfo.js
function(next) {
          async.map([src,dest], function(path, done) {
            fs.stat(path, function(err, stat) {
              done(null, stat); // Ignore error
            });
          },
          function(err, results) {
            statSrc  = results[0];
            statDest = results[1];
            if(!statSrc) {
              // src is needed
              next(new Error('File not found: ' + src));
            }
            // Ignore anything that is not directory or file
            if(!(statSrc.isFile() || statSrc.isDirectory())) {
              grunt.verbose.writeln('  Ignore:'+' Source is not a file or a directory.'.grey);
              return done(null, false);
            }

            // Add stat to options for user defined transform & process
            options.statSrc  = statSrc;
            options.statDest = statDest;

            next();
          });
        }
function(next) {
          async.map([src,dest], function(path, done) {
            fs.stat(path, function(err, stat) {
              done(null, stat); // Ignore error
            });
          },
          function(err, results) {
            statSrc  = results[0];
            statDest = results[1];
            if(!statSrc) {
              // src is needed
              next(new Error('File not found: ' + src));
            }
            // Ignore anything that is not directory or file
            if(!(statSrc.isFile() || statSrc.isDirectory())) {
              grunt.verbose.writeln('  Ignore:'+' Source is not a file or a directory.'.grey);
              return done(null, false);
            }

            // Add stat to options for user defined transform & process
            options.statSrc  = statSrc;
            options.statDest = statDest;

            next();
          });
        }
function ( next ) { async . map ( [ src , dest ] , function ( path , done ) { fs . stat ( path , function ( err , stat ) { done ( null , stat ) ; // Ignore error } ) ; } , function ( err , results ) { statSrc = results [ 0 ] ; statDest = results [ 1 ] ; if ( ! statSrc ) { // src is needed next ( new Error ( 'File not found: ' + src ) ) ; } // Ignore anything that is not directory or file if ( ! ( statSrc . isFile ( ) || statSrc . isDirectory ( ) ) ) { grunt . verbose . writeln ( '  Ignore:' + ' Source is not a file or a directory.' . grey ) ; return done ( null , false ) ; } // Add stat to options for user defined transform & process options . statSrc = statSrc ; options . statDest = statDest ; next ( ) ; } ) ; }
Get src and dest stat asynchronously
Get src and dest stat asynchronously