function expand(list) {
      var expanded = [];
      list.forEach(function(listEl) {
        // Wildcard present on directory names ?
        if(listEl.search(/\*[^\/]*\//) > -1 || listEl.search(/\*\*[^\/]*\//) > -1) {
          var match = listEl.match(/^([^*]+\/|)(.*)/);
          var root = match[1];
          var rest = match[2];
          var restRegex = rest.replace(/\*\*/g, ".*").replace(/\*/g, "[^\\/]*");
          restRegex = new RegExp(restRegex);
          
          _ls('-R', root).filter(function (e) {
            return restRegex.test(e);
          }).forEach(function(file) {
            expanded.push(file);
          });
        }
        // Wildcard present on file names ?
        else if (listEl.search(/\*/) > -1) {
          _ls('', listEl).forEach(function(file) {
            expanded.push(file);
          });
        } else {
          expanded.push(listEl);
        }
      });
      return expanded;
    }
function expand(list) {
      var expanded = [];
      list.forEach(function(listEl) {
        
        if(listEl.search(/\*[^\/]*\
          var match = listEl.match(/^([^*]+\/|)(.*)/);
          var root = match[1];
          var rest = match[2];
          var restRegex = rest.replace(/\*\*/g, ".*").replace(/\*/g, "[^\\/]*");
          restRegex = new RegExp(restRegex);
          
          _ls('-R', root).filter(function (e) {
            return restRegex.test(e);
          }).forEach(function(file) {
            expanded.push(file);
          });
        }
        
        else if (listEl.search(/\*/) > -1) {
          _ls('', listEl).forEach(function(file) {
            expanded.push(file);
          });
        } else {
          expanded.push(listEl);
        }
      });
      return expanded;
    }
function expand ( list ) { var expanded = [ ] ; list . forEach ( function ( listEl ) { // Wildcard present on directory names ? if ( listEl . search ( / \*[^\/]*\/ / ) > - 1 || listEl . search ( / \*\*[^\/]*\/ / ) > - 1 ) { var match = listEl . match ( / ^([^*]+\/|)(.*) / ) ; var root = match [ 1 ] ; var rest = match [ 2 ] ; var restRegex = rest . replace ( / \*\* / g , ".*" ) . replace ( / \* / g , "[^\\/]*" ) ; restRegex = new RegExp ( restRegex ) ; _ls ( '-R' , root ) . filter ( function ( e ) { return restRegex . test ( e ) ; } ) . forEach ( function ( file ) { expanded . push ( file ) ; } ) ; } // Wildcard present on file names ? else if ( listEl . search ( / \* / ) > - 1 ) { _ls ( '' , listEl ) . forEach ( function ( file ) { expanded . push ( file ) ; } ) ; } else { expanded . push ( listEl ) ; } } ) ; return expanded ; }
Expands wildcards with matching (ie. existing) file names. For example: expand(['file*.js']) = ['file1.js', 'file2.js', ...] (if the files 'file1.js', 'file2.js', etc, exist in the current dir)
Expands wildcards with matching ( ie . existing ) file names . For example : expand ( [ file * . js ] ) = [ file1 . js file2 . js ... ] ( if the files file1 . js file2 . js etc exist in the current dir )