Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add multi glob functionality for inclusion/exclusion #84

Closed
pajooh opened this issue Jan 15, 2014 · 13 comments
Closed

add multi glob functionality for inclusion/exclusion #84

pajooh opened this issue Jan 15, 2014 · 13 comments

Comments

@pajooh
Copy link

pajooh commented Jan 15, 2014

like

glob([ "src/**/*.js", "!src/**/*.spec.js", "!src/assets/**/*.js" ])

as globs do

@jonathanrdelgado
Copy link

Dupe of #36

@sindresorhus
Copy link
Contributor

Check out globby

globs doesn't work correctly as it doesn't handle negates ['*', '!cake'] or filter out duplicates.

I still think this should be built into node-glob though.

@shellscape
Copy link

👍 to getting this into node-glob

@intervalia
Copy link

This is what I did to get a temporary version to work:

function globArray(patterns, options) {
  var i, list = [];
  if (!Array.isArray(patterns)) {
    patterns = [patterns];
  }

  patterns.forEach(function (pattern) {
    if (pattern[0] === "!") {
      i = list.length-1;
      while( i > -1) {
        if (!minimatch(list[i], pattern)) {
          list.splice(i,1);
        }
        i--;
      }

    }
    else {
      var newList = glob.sync(pattern, options);
      newList.forEach(function(item){
        if (list.indexOf(item)===-1) {
          list.push(item);
        }
      });
    }
  });

  return list;
}

Maybe you could do something similar initially, just to get some level of support.

@alexander-akait
Copy link

need 👍

@yocontra
Copy link

Every implementation right now just globs everything and then checks the negations afterwards. When dealing with something like this ['**/*.js', '!node_modules/**'] the performance is awful because node-glob is still traversing the node_modules folder and finding results. This needs to be solved in node-glob itself otherwise the perf is going to stay bad. I think we can get a sizable bounty on this if somebody wants to dig in and make a PR for adding this.

@yocontra
Copy link

I'm willing to personally put up $500 for a fix for this - not sure if I should do a bountysource or whatever to make that official

@jonathanrdelgado
Copy link

@contra in #36, it was stated this would not be added to the package.

Use https://github.com/sindresorhus/globby, keep your $500 and buy yourself a beer.

@UltCombo
Copy link

@jonathandelgado globby has inherent perf issues as @contra has already stated.

in #36, it was stated this would not be added to the package.

As far as I can see, @isaacs has only stated that it was "complicated and hard", not that he would never accept a PR nor change his mind in 2 years.

@yocontra
Copy link

I've put up some stuff on bountysource for this and a few other issues on node-glob if anyone is interested

@isaacs
Copy link
Owner

isaacs commented Dec 30, 2014

I don't want to add multi-glob functionality, per se, but I do think it's reasonable to add an exclusions set, as a better way to do negative globs.

@isaacs
Copy link
Owner

isaacs commented Dec 30, 2014

See: #115 (comment)

@isaacs isaacs closed this as completed Dec 30, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants