lib/bagofcli.js
function files(items, opts) {
  opts = opts || {};
  var data = [];

  function addMatch(item) {
    if (opts.match === undefined || (opts.match && item.match(new RegExp(opts.match)))) {
      data.push(item);
    }
  }

  items.forEach(function (item) {
    var stat = fs.statSync(item);

    if (stat.isFile()) {
      addMatch(item);

    } else if (stat.isDirectory()) {
      var _items = wrench.readdirSyncRecursive(item);
      _items.forEach(function (_item) {
        _item = p.join(item, _item);
        if (fs.statSync(_item).isFile()) {
          addMatch(_item);
        }
      });
    }
  });
  return data;
}
function files(items, opts) {
  opts = opts || {};
  var data = [];

  function addMatch(item) {
    if (opts.match === undefined || (opts.match && item.match(new RegExp(opts.match)))) {
      data.push(item);
    }
  }

  items.forEach(function (item) {
    var stat = fs.statSync(item);

    if (stat.isFile()) {
      addMatch(item);

    } else if (stat.isDirectory()) {
      var _items = wrench.readdirSyncRecursive(item);
      _items.forEach(function (_item) {
        _item = p.join(item, _item);
        if (fs.statSync(_item).isFile()) {
          addMatch(_item);
        }
      });
    }
  });
  return data;
}
function files ( items , opts ) { opts = opts || { } ; var data = [ ] ; function addMatch ( item ) { if ( opts . match === undefined || ( opts . match && item . match ( new RegExp ( opts . match ) ) ) ) { data . push ( item ) ; } } items . forEach ( function ( item ) { var stat = fs . statSync ( item ) ; if ( stat . isFile ( ) ) { addMatch ( item ) ; } else if ( stat . isDirectory ( ) ) { var _items = wrench . readdirSyncRecursive ( item ) ; _items . forEach ( function ( _item ) { _item = p . join ( item , _item ) ; if ( fs . statSync ( _item ) . isFile ( ) ) { addMatch ( _item ) ; } } ) ; } } ) ; return data ; }
Get an array of files contained in specified items.
When a directory is specified, all files contained within that directory and its sub-directories will be included.

@param {Array} items: an array of files and/or directories
@param {Object} opts: optional
- match: regular expression to match against the file name
@return {Array} all files
Get an array of files contained in specified items . When a directory is specified all files contained within that directory and its sub - directories will be included .