index.js
function(fs, ourGlob, negatives, opt) {

    // remove path relativity to make globs make sense
    ourGlob = resolveGlob(fs, ourGlob, opt);
    var ourOpt = extend({}, opt);
    delete ourOpt.root;

    // create globbing stuff
    var globber = new glob.Glob(fs, ourGlob, ourOpt);
    // extract base path from glob
    var basePath = opt.base || glob2base(globber);

    // create stream and map events from globber to it
    var stream = through2.obj(negatives.length ? filterNegatives : undefined);

    var found = false;

    globber.on('error', stream.emit.bind(stream, 'error'));
    globber.once('end', function(){
      if (opt.allowEmpty !== true && !found && globIsSingular(globber)) {
        stream.emit('error', new Error('File not found with singular glob'));
      }

      stream.end();
    });
    globber.on('match', function(filename) {
      found = true;

      stream.write({
        cwd: opt.cwd,
        base: basePath,
        path: fs.resolve(opt.cwd, filename)
      });
    });

    return stream;

    function filterNegatives(filename, enc, cb) {
      var matcha = isMatch.bind(null, filename);
      if (negatives.every(matcha)) {
        cb(null, filename); // pass
      } else {
        cb(); // ignore
      }
    }
  }
function(fs, ourGlob, negatives, opt) {

    // remove path relativity to make globs make sense
    ourGlob = resolveGlob(fs, ourGlob, opt);
    var ourOpt = extend({}, opt);
    delete ourOpt.root;

    // create globbing stuff
    var globber = new glob.Glob(fs, ourGlob, ourOpt);
    // extract base path from glob
    var basePath = opt.base || glob2base(globber);

    // create stream and map events from globber to it
    var stream = through2.obj(negatives.length ? filterNegatives : undefined);

    var found = false;

    globber.on('error', stream.emit.bind(stream, 'error'));
    globber.once('end', function(){
      if (opt.allowEmpty !== true && !found && globIsSingular(globber)) {
        stream.emit('error', new Error('File not found with singular glob'));
      }

      stream.end();
    });
    globber.on('match', function(filename) {
      found = true;

      stream.write({
        cwd: opt.cwd,
        base: basePath,
        path: fs.resolve(opt.cwd, filename)
      });
    });

    return stream;

    function filterNegatives(filename, enc, cb) {
      var matcha = isMatch.bind(null, filename);
      if (negatives.every(matcha)) {
        cb(null, filename); // pass
      } else {
        cb(); // ignore
      }
    }
  }
function ( fs , ourGlob , negatives , opt ) { // remove path relativity to make globs make sense ourGlob = resolveGlob ( fs , ourGlob , opt ) ; var ourOpt = extend ( { } , opt ) ; delete ourOpt . root ; // create globbing stuff var globber = new glob . Glob ( fs , ourGlob , ourOpt ) ; // extract base path from glob var basePath = opt . base || glob2base ( globber ) ; // create stream and map events from globber to it var stream = through2 . obj ( negatives . length ? filterNegatives : undefined ) ; var found = false ; globber . on ( 'error' , stream . emit . bind ( stream , 'error' ) ) ; globber . once ( 'end' , function ( ) { if ( opt . allowEmpty !== true && ! found && globIsSingular ( globber ) ) { stream . emit ( 'error' , new Error ( 'File not found with singular glob' ) ) ; } stream . end ( ) ; } ) ; globber . on ( 'match' , function ( filename ) { found = true ; stream . write ( { cwd : opt . cwd , base : basePath , path : fs . resolve ( opt . cwd , filename ) } ) ; } ) ; return stream ; function filterNegatives ( filename , enc , cb ) { var matcha = isMatch . bind ( null , filename ) ; if ( negatives . every ( matcha ) ) { cb ( null , filename ) ; // pass } else { cb ( ) ; // ignore } } }
creates a stream for a single glob or filter
creates a stream for a single glob or filter