src/utilities/cmd.js
function globs(sourcePath, ignore, commands, done) {
  var expression = /\$g\[(.+?)\]/g;
  var result = [];
  each(commands, function(command, next) {
    var map = {};
    var match;
    var matches = [];
    while ((match = expression.exec(command))) matches.push(match);
    each(matches, function(patternMatch, next) {
      find(patternMatch[1], sourcePath, ignore, function(err, relativePaths) {
        if (err) return next(err);
        map[patternMatch[1]] = relativePaths;
        next();
      });
    }, function(err) {
      if (err) return next(err);
      result.push(command.replace(expression, function(match, matchKey) {
        return map[matchKey].join(' ');
      }));
      next();
    });
  }, function(err) {
    if (err) return done(err);
    done(undefined, result);
  });
}
function globs(sourcePath, ignore, commands, done) {
  var expression = /\$g\[(.+?)\]/g;
  var result = [];
  each(commands, function(command, next) {
    var map = {};
    var match;
    var matches = [];
    while ((match = expression.exec(command))) matches.push(match);
    each(matches, function(patternMatch, next) {
      find(patternMatch[1], sourcePath, ignore, function(err, relativePaths) {
        if (err) return next(err);
        map[patternMatch[1]] = relativePaths;
        next();
      });
    }, function(err) {
      if (err) return next(err);
      result.push(command.replace(expression, function(match, matchKey) {
        return map[matchKey].join(' ');
      }));
      next();
    });
  }, function(err) {
    if (err) return done(err);
    done(undefined, result);
  });
}
function globs ( sourcePath , ignore , commands , done ) { var expression = / \$g\[(.+?)\] / g ; var result = [ ] ; each ( commands , function ( command , next ) { var map = { } ; var match ; var matches = [ ] ; while ( ( match = expression . exec ( command ) ) ) matches . push ( match ) ; each ( matches , function ( patternMatch , next ) { find ( patternMatch [ 1 ] , sourcePath , ignore , function ( err , relativePaths ) { if ( err ) return next ( err ) ; map [ patternMatch [ 1 ] ] = relativePaths ; next ( ) ; } ) ; } , function ( err ) { if ( err ) return next ( err ) ; result . push ( command . replace ( expression , function ( match , matchKey ) { return map [ matchKey ] . join ( ' ' ) ; } ) ) ; next ( ) ; } ) ; } , function ( err ) { if ( err ) return done ( err ) ; done ( undefined , result ) ; } ) ; }
Iterates through each command and expands each glob pattern.
@param {string} sourcePath
@param {Array.<string>} commands
@param {function(Error, Array.<string>=)} done
Iterates through each command and expands each glob pattern .