lib/epm/fs-explorer.js
function getFiles(dir, pattern, fn) {

  if ("function" === typeof pattern) {
    fn = pattern;
    pattern = undefined;
  }

  pattern = pattern || /.*/ig;

  fs.readdir(dir, function(err, files){
    if (err) return fn && fn(err);

    async.map(
      files,
      function(f, cb) {
        fs.stat(path.join(dir, f), function(err, stats){
          if (err) return cb && cb(err);

          cb && cb(null, { filename: f, stats: stats })  
        })
      },
      function(err, stats){
        if (err) return fn && fn(err);

        var fstats = stats.filter(function(f){
          return f.stats.isFile() && pattern.test(f.filename);
        });

        fn && fn(null, fstats);
    });

  });
}
function getFiles(dir, pattern, fn) {

  if ("function" === typeof pattern) {
    fn = pattern;
    pattern = undefined;
  }

  pattern = pattern || /.*/ig;

  fs.readdir(dir, function(err, files){
    if (err) return fn && fn(err);

    async.map(
      files,
      function(f, cb) {
        fs.stat(path.join(dir, f), function(err, stats){
          if (err) return cb && cb(err);

          cb && cb(null, { filename: f, stats: stats })  
        })
      },
      function(err, stats){
        if (err) return fn && fn(err);

        var fstats = stats.filter(function(f){
          return f.stats.isFile() && pattern.test(f.filename);
        });

        fn && fn(null, fstats);
    });

  });
}
function getFiles ( dir , pattern , fn ) { if ( "function" === typeof pattern ) { fn = pattern ; pattern = undefined ; } pattern = pattern || / .* / ig ; fs . readdir ( dir , function ( err , files ) { if ( err ) return fn && fn ( err ) ; async . map ( files , function ( f , cb ) { fs . stat ( path . join ( dir , f ) , function ( err , stats ) { if ( err ) return cb && cb ( err ) ; cb && cb ( null , { filename : f , stats : stats } ) } ) } , function ( err , stats ) { if ( err ) return fn && fn ( err ) ; var fstats = stats . filter ( function ( f ) { return f . stats . isFile ( ) && pattern . test ( f . filename ) ; } ) ; fn && fn ( null , fstats ) ; } ) ; } ) ; }
Get files from the `dir` filtered with `pattern`

@param {String} dir
@param {Regex} pattern
@param {requestCallback} fn callback
Get files from the dir filtered with pattern