Force convert to array of files if glob pattern
967155
def files_array(files)
      return [] unless files
      files.is_a?(Array) ? files : pattern_to_filelist(files.to_s)
    end
754391
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);
  }
193986
function cog(glob) {
  if (typeof glob === 'undefined') {
    var glob = '**/*';
  }

  // Collect all files, before we filter stream
  var allFiles = {};
  var collectFilesStream = through.obj(function(file, enc, cb) {
    allFiles[file.relative] = file;
    cb();
  }, function(cb) {
    _.each(allFiles, function(file) {
      collectFilesStream.push(file);
    });
    cb();
  });

  // Get all includes for a file
  function getIncludes(file) {
    var content = String(file.contents);
    var matches = [];

    while (regexMatch = DIRECTIVE_REGEX.exec(content)) {
      matches.push(regexMatch);
    }

    // For every require fetch it's matching files
    var fileLists = _.map(matches, function(match) {
      return globMatch(match, file).sort();
    });

    // Merge all matching file lists into one concat list
    var order = _.reduce(fileLists, function(memo, fileList) {
      return _.union(memo, fileList);
    }, []);

    // And self to include list
    order.push(file.relative);
    return order;
  }

  function getRelativeDir(file) {
    var relativeDir = _.initial(file.relative.split('/')).join('/');
    if (relativeDir.length > 0) {
      relativeDir += '/';
    }
    return relativeDir;
  }

  // Translate an include match to a glob
  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);
  }


  // creating a stream through which each file will pass
  var concatFiles = [];
  var buildIncludesStream = through.obj(function(file, enc, cb) {
    if (file.isStream()) {
      this.emit('error', new PluginError(PLUGIN_NAME, 'Streams are not supported!'));
      return cb();
    }

    // Attach includes to masterfile
    file.includes = _.filter(_.map(getIncludes(file), function(filename) {
      return allFiles[filename];
    }, function(file) {
      return !!file;
    }));

    this.push(file);
    cb();
  });

  /*
   * Construct the stream.
   * 
   * Steps:
   * 1. Build a list of all files in the stream for use later
   * 2. Filter files to only desired master concat files
   * 3. Build concat manifests data objects for each of the master files
   */
  var stream = sc(
    collectFilesStream,
    filter(glob),
    buildIncludesStream
  );

  return stream;
}
780823
def extract_pattern(pattern: str, ifiles: List[str]) -> Dict[str, any]:
    ''''''
    res = glob_wildcards(pattern, [])
    for ifile in ifiles:
        matched = glob_wildcards(pattern, [ifile])
        for key in matched.keys():
            if not matched[key]:
                #env.logger.warning('Filename {} does not match pattern {}. None returned.'.format(ifile, pattern))
                res[key].append(None)
            else:
                res[key].extend(matched[key])
    return res
889456
function(fs, globs, opt) {
    if (!opt) opt = {};
    if (typeof opt.cwd !== 'string') opt.cwd = fs.resolve('.');
    if (typeof opt.dot !== 'boolean') opt.dot = false;
    if (typeof opt.silent !== 'boolean') opt.silent = true;
    if (typeof opt.nonull !== 'boolean') opt.nonull = false;
    if (typeof opt.cwdbase !== 'boolean') opt.cwdbase = false;
    if (opt.cwdbase) opt.base = opt.cwd;

    // only one glob no need to aggregate
    if (!Array.isArray(globs)) globs = [globs];

    var positives = [];
    var negatives = [];

    var ourOpt = extend({}, opt);
    delete ourOpt.root;
    
    globs.forEach(function(glob, index) {
      if (typeof glob !== 'string' && !(glob instanceof RegExp)) {
        throw new Error('Invalid glob at index ' + index);
      }

      var globArray = isNegative(glob) ? negatives : positives;

      // create Minimatch instances for negative glob patterns
      if (globArray === negatives && typeof glob === 'string') {
        var ourGlob = resolveGlob(glob, opt);
        glob = new Minimatch(ourGlob, ourOpt);
      }

      globArray.push({
        index: index,
        glob: glob
      });
    });

    if (positives.length === 0) throw new Error('Missing positive glob');

    // only one positive glob no need to aggregate
    if (positives.length === 1) return streamFromPositive(positives[0]);

    // create all individual streams
    var streams = positives.map(streamFromPositive);

    // then just pipe them to a single unique stream and return it
    var aggregate = new Combine(streams);
    var uniqueStream = unique('path');
    var returnStream = aggregate.pipe(uniqueStream);

    aggregate.on('error', function (err) {
      returnStream.emit('error', err);
    });

    return returnStream;

    function streamFromPositive(positive) {
      var negativeGlobs = negatives.filter(indexGreaterThan(positive.index)).map(toGlob);
      return gs.createStream(fs, positive.glob, negativeGlobs, opt);
    }
  }
332196
function(o) {
    var a = [];
    _.each(o, function(value, key) {
      a.push({file:key,method:value});
    });
    return a;
  }
944735
function(dir) {
      var results = [];

      var list = fs.readdirSync(dir);

      list.forEach(function(file) {
        // Check for every given pattern, regardless of whether it is an array or a string
        var matchesSomeExclude = [].concat(options.exclude).some(function(regexp) {
          return file.match(regexp) != null;
        });

        if(!matchesSomeExclude) {
          var matchesSomePattern = [].concat(options.match).some(function(regexp) {
            return file.match(regexp) != null;
          });

          file = path.resolve(dir, file);
          var stat = fs.statSync(file);

          if (stat && stat.isDirectory()) {
            if(matchesSomePattern) {
              results = results.concat(file);
            }
            results = results.concat(walk(file));
          }
        }
      });

      return results;
    }
1367987
function globWithPromsie(pattern) {
  return new Promise((resolve, reject) => {
    glob(pattern, function(err, files) {
      if (err) {
        reject(err);
      }

      if (files.length === 0) {
        console.warn('pattern "' + pattern + '" does not match any file');
      }

      resolve(files);
    });
  });
}
657043
function collectInputFiles(pattern) {
  return new Promise((resolve, reject) => {
    glob(pattern, {root: SRC_DIR, nomount: true}, (err, files) => {
      if (err) {
        return reject(err);
      }
      resolve(files);
    });
  });
}
1330064
function(/* Array */ files) {

                    var preprocessor;

                    if (_.isEmpty(files)) {
                        return preprocessor;
                    }

                    // collect all the possible extensions
                    // and remove duplicates
                    files = _.chain(files).map(function (/* string */ file) {

                        var ext = path.extname(file).split('.');

                        return ext[ext.length - 1];

                    }).uniq().value();

                    preprocessor = _.find(Object.keys(plugin.preprocessors), function (/* String */ key) {

                        var value = plugin.preprocessors[key],
                            exts = value.split(/[,\s]+/),

                            matches = _.filter(files, function (/* String */ ext) {
                                return exts.indexOf(ext) !== -1;
                            });

                        return !_.isEmpty(matches);

                    });

                    return preprocessor;

                }
1014332
function cmd(patterns, options) {
  var str = normalize(patterns);
  var keys = Object.keys(options);
  var args = [];
  var valid = [
    'dotglob',
    'extglob',
    'failglob',
    'globstar',
    'nocaseglob',
    'nullglob'
  ];

  for (var i = 0; i < keys.length; i++) {
    var key = keys[i];
    if (valid.indexOf(key) !== -1) {
      args.push('-O', key);
    }
  }

  args.push('-c', 'for i in ' + str + '; do echo $i; done');
  return args;
}
286816
function (o, cb) {
    if (!o.src) {
      throw new Error('glob missing');
    }
    if (!o.out) {
      throw new Error('output dir missing');
    }

    var opts = _.extend({}, defaults, o);
    if (opts.style && path.basename(opts.style).indexOf('.') === -1) {
      opts.style = path.join(opts.style, replaceExtension(opts.name, '.' + opts.processor));
    }
    vfs.src(opts.src)
      .pipe(sprite(opts))
      .pipe(through2.obj(writeFile))
      .on('data', noop)
      .on('end', function () {
        if (_.isFunction(cb)) {
          cb();
        }
      });
  }
681541
function addFiles(pattern, cb){
    glob(pattern, function(err, files){
      if(err) throw err;

      async.each(files, readFile, function(err){
        if(err) throw err;
        if(cb) cb();
      });
    });
  }
187044
def separate_globs(globs):
	""""""
	exclude = []
	include = []

	for path in globs:
		if path.startswith("!"):
			exclude.append(path[1:])
		else:
			include.append(path)

	return (exclude, include)
643402
public static function unlinkGlobFiles( $glob )
	{
		$files  = glob( $glob );
		$return = array();

		foreach ( $files as $file )
		{
			if ( ! is_dir( $file ) )
			{
				if ( unlink( $file ) === true )
				{
					$return[] = $file;
				}
			}
		}

		return $return;
	}
420846
def iglob(path_glob):
    """"""
    if _CHECK_RECURSIVE_GLOB.search(path_glob):
        msg = """invalid glob %r: recursive glob "**" must be used alone"""
        raise ValueError(msg % path_glob)
    if _CHECK_MISMATCH_SET.search(path_glob):
        msg = """invalid glob %r: mismatching set marker '{' or '}'"""
        raise ValueError(msg % path_glob)
    return _iglob(path_glob)
444098
function convertGlobPaths(globs) {
  return globs
    .map(globString => glob.sync(globString))
    .reduce((previous, current) => previous.concat(current), []);
}