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

Support multiple globs and negation for .src() #7

Closed
yocontra opened this issue Jul 21, 2013 · 17 comments
Closed

Support multiple globs and negation for .src() #7

yocontra opened this issue Jul 21, 2013 · 17 comments

Comments

@yocontra
Copy link
Member

Should work like this

gulp.src("./css/**/*.css")

or

gulp.src(["./css/vendor/*.css", "./css/app/*.css"])
@phated
Copy link
Member

phated commented Aug 16, 2013

If it is going to take an array or string as src, then I think ignore should be the negated glob like grunt:

gulp.files(["./css/vendor/*.css", "!./css/app/*.css"])

ref #6

@yocontra
Copy link
Member Author

@phated Ignore will be in an option as the second argument like '.src(glob, {ignore: glob})'. Your main glob and ignore glob should also support arrays. I'm open to grunt style but I might need some convincing because I never saw the point

@phated
Copy link
Member

phated commented Aug 21, 2013

If it is implemented with node-glob, the negate syntax should already work, as per https://github.com/isaacs/node-glob#comparisons-to-other-fnmatchglob-implementations

@yocontra
Copy link
Member Author

@phated Yeah it will probably support both. I want an alternate for people who don't want to learn globs past * and **.

@yocontra
Copy link
Member Author

/cc @robrich

@robrich
Copy link
Contributor

robrich commented Oct 10, 2013

I dug into minimatch and node-glob quite a bit yesterday. It supports "!./.js" but not "{./.js,!./node_modules/}" making it pretty much useless. Grunt wraps node-glob in processPatterns() which flattens the results, specifically checks for globs that start with ! and manually handles them differently. All else being equal, I'd like to fix node-glob and/or minimatch, but @contra suggested starting over as both libraries are not very well tested nor maintained. Perhaps one of the dozen node-glob wrappers / work-a-likes already does this?

@yocontra
Copy link
Member Author

@robrich - Really the glob module does three things

  • Generates a regex from a glob (or set of globs)
  • Recursively crawls the file system (there are modules for this)
  • Matches file names against the regex

Only the regex generation needs to be split out and we can use existing crawlers and fs watchers for the other step

@hparra
Copy link

hparra commented Dec 3, 2013

Pinging here. ATM the globbing impl cripples the expected behavior of several plugins with regards to globbed ignores, smart renaming and directory structure replication (another issue?).

Perhaps replicating grunt's globbing interface is the best route, though I personally don't mind the ignore method. I actually think it's more expressive and probably makes the filtering impl easier.

This was referenced Dec 3, 2013
@yocontra
Copy link
Member Author

yocontra commented Dec 4, 2013

FYI for anyone currently having problems with this you can pipe multiple .src() calls into eachother to hold you over. For negation you can use the gulp-ignore plugin. This fix is taking longer than expected due to some tricky edge cases.

@yocontra
Copy link
Member Author

yocontra commented Dec 7, 2013

FINALLY finished in 3.0

@yocontra yocontra closed this as completed Dec 7, 2013
@Jakobud
Copy link

Jakobud commented Jun 11, 2014

.src() still doesn't accept an glob of paths to ignore, correct?

@yocontra
Copy link
Member Author

@Jakobud it does, please read the docs. You can pass multiple positive or negative globs

@Jakobud
Copy link

Jakobud commented Jun 11, 2014

Where in the docs? https://github.com/gulpjs/gulp/blob/master/docs/API.md Am I missing something?

@appleboy
Copy link
Contributor

@Jakobud
Copy link

Jakobud commented Jun 11, 2014

Uh... okay I'm not sure what that has to do with gulp documentation or how I would have ever found that page.... but anyways, I still don't see anything on there about ignoring an array of paths when using .src().....

@Jakobud
Copy link

Jakobud commented Jun 11, 2014

Okay I think I figured it out. I didn't see this anywhere in the gulp docs, but I could just do a array of globs like this:

[ 'myfile.js', '!ignoredFile.js' ]

@yocontra
Copy link
Member Author

I'll take a PR to make the docs better if you feel they are inadequate - they should probably include all of the info vinyl-fs docs do

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants