index.js
function lookup(dir, recurse) {
  if (typeof dir !== 'string') {
    throw new Error('export-files expects a string as the first argument.');
  }

  var key = 'lookup:' + dir + ('' + recurse);
  if (cache.hasOwnProperty(key)) {
    return cache[key];
  }

  var files = fs.readdirSync(dir);
  var len = files.length;
  var res = [];

  if (recurse === false) return map(files, resolve(dir));

  while (len--) {
    var fp = path.resolve(dir, files[len]);
    if (isDir(fp)) {
      res.push.apply(res, lookup(fp, recurse));
    } else {
      res.push(fp);
    }
  }
  return (cache[key] = res);
}
function lookup(dir, recurse) {
  if (typeof dir !== 'string') {
    throw new Error('export-files expects a string as the first argument.');
  }

  var key = 'lookup:' + dir + ('' + recurse);
  if (cache.hasOwnProperty(key)) {
    return cache[key];
  }

  var files = fs.readdirSync(dir);
  var len = files.length;
  var res = [];

  if (recurse === false) return map(files, resolve(dir));

  while (len--) {
    var fp = path.resolve(dir, files[len]);
    if (isDir(fp)) {
      res.push.apply(res, lookup(fp, recurse));
    } else {
      res.push(fp);
    }
  }
  return (cache[key] = res);
}
function lookup ( dir , recurse ) { if ( typeof dir !== 'string' ) { throw new Error ( 'export-files expects a string as the first argument.' ) ; } var key = 'lookup:' + dir + ( '' + recurse ) ; if ( cache . hasOwnProperty ( key ) ) { return cache [ key ] ; } var files = fs . readdirSync ( dir ) ; var len = files . length ; var res = [ ] ; if ( recurse === false ) return map ( files , resolve ( dir ) ) ; while ( len -- ) { var fp = path . resolve ( dir , files [ len ] ) ; if ( isDir ( fp ) ) { res . push . apply ( res , lookup ( fp , recurse ) ) ; } else { res . push ( fp ) ; } } return ( cache [ key ] = res ) ; }
Recursively read directories, starting with the given `dir`.

@param  {String} `dir`
@param  {Boolean} `recurse` Should the function recurse?
@return {Array} Returns an array of files.
Recursively read directories starting with the given dir .