index.js
function globMatch(match, file) {
    var directiveType = match[1];
    var globPattern = match[2]; // relative file

    // require all files under a directory
    if (directiveType.indexOf('_tree') !== -1) {
      globPattern = globPattern.concat('/**/*');
      directiveType = directiveType.replace('_tree', '');
    }

    // require only first level files in a directory
    if (directiveType.indexOf('_directory') !== -1) {
      globPattern = globPattern.concat('/*');
      directiveType = directiveType.replace('_directory', '');
    }

    // Only require and include directives are allowed
    if (directiveType !== 'require' && directiveType !== 'include') {
      return [];
    }

    // Add file extension to glob pattern if not already set
    var jsExt = '.js';
    if (globPattern.substr(globPattern.length-jsExt.length).indexOf(jsExt) !== 0) {
      globPattern += jsExt;
    } 

    // Append the current dir to include so we can match the glob against the file list
    var relativeDir = getRelativeDir(file);
    globPattern = relativeDir+globPattern;

    var possibleIncludes = [];
    _.each(_.keys(allFiles), function(fileName) {
      // Only process files in the current directory. ../ will not work.
      if (fileName.indexOf(relativeDir) !== 0) {
        return;
      }

      possibleIncludes.push(fileName);
    });
    
    return minimatch.match(possibleIncludes, globPattern);
  }
function globMatch(match, file) {
    var directiveType = match[1];
    var globPattern = match[2]; // relative file

    // require all files under a directory
    if (directiveType.indexOf('_tree') !== -1) {
      globPattern = globPattern.concat('/**/*');
      directiveType = directiveType.replace('_tree', '');
    }

    // require only first level files in a directory
    if (directiveType.indexOf('_directory') !== -1) {
      globPattern = globPattern.concat('/*');
      directiveType = directiveType.replace('_directory', '');
    }

    // Only require and include directives are allowed
    if (directiveType !== 'require' && directiveType !== 'include') {
      return [];
    }

    // Add file extension to glob pattern if not already set
    var jsExt = '.js';
    if (globPattern.substr(globPattern.length-jsExt.length).indexOf(jsExt) !== 0) {
      globPattern += jsExt;
    } 

    // Append the current dir to include so we can match the glob against the file list
    var relativeDir = getRelativeDir(file);
    globPattern = relativeDir+globPattern;

    var possibleIncludes = [];
    _.each(_.keys(allFiles), function(fileName) {
      // Only process files in the current directory. ../ will not work.
      if (fileName.indexOf(relativeDir) !== 0) {
        return;
      }

      possibleIncludes.push(fileName);
    });
    
    return minimatch.match(possibleIncludes, globPattern);
  }
function globMatch ( match , file ) { var directiveType = match [ 1 ] ; var globPattern = match [ 2 ] ; // relative file // require all files under a directory if ( directiveType . indexOf ( '_tree' ) !== - 1 ) { globPattern = globPattern . concat ( '/**/*' ) ; directiveType = directiveType . replace ( '_tree' , '' ) ; } // require only first level files in a directory if ( directiveType . indexOf ( '_directory' ) !== - 1 ) { globPattern = globPattern . concat ( '/*' ) ; directiveType = directiveType . replace ( '_directory' , '' ) ; } // Only require and include directives are allowed if ( directiveType !== 'require' && directiveType !== 'include' ) { return [ ] ; } // Add file extension to glob pattern if not already set var jsExt = '.js' ; if ( globPattern . substr ( globPattern . length - jsExt . length ) . indexOf ( jsExt ) !== 0 ) { globPattern += jsExt ; } // Append the current dir to include so we can match the glob against the file list var relativeDir = getRelativeDir ( file ) ; globPattern = relativeDir + globPattern ; var possibleIncludes = [ ] ; _ . each ( _ . keys ( allFiles ) , function ( fileName ) { // Only process files in the current directory. ../ will not work. if ( fileName . indexOf ( relativeDir ) !== 0 ) { return ; } possibleIncludes . push ( fileName ) ; } ) ; return minimatch . match ( possibleIncludes , globPattern ) ; }
Translate an include match to a glob
Translate an include match to a glob