-
-
Notifications
You must be signed in to change notification settings - Fork 359
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
glob-based include/exclude functionality #84
Conversation
… for micromatch, fixes #54
I see a potential problem with the include implementation. If both Also, if someone wished to include the entire contents of their source directory without using |
Personally, I have come to prefer If you are going to provide both |
] | ||
} | ||
}} | ||
``` | ||
|
||
> Note: exclude defaults to `['test', 'test{,-*}.js']`, which would exclude |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's a note paragraph at the end of the readme which is in italics, yet this is a quote. Would be nice to be consistent.
I guess the README could make that more clear (though the section after |
There are default exclusions though. Would be good to allow a particular module to be covered, even if generally all modules are excluded. |
@jamestalmage hit on this a bit. It would be possible to have exclusion negations with a leading {
exclude: ['!node_modules/glob']
} This is effectively the same as the current idea of include, where a file is included despite having been excluded in other patterns. |
Yep, I think that's why it may make sense to have separate include/exclude globs, with the following defaults: {
"include": "**/*",
"exclude": ["**/node_modules/", "**/test/**", "**/test.js"]
} |
@jamestalmage That example is effectively what the What would be nice, and I was hoping to accomplish in a future PR, is to have something like: {
include: ['src/**/*.js', 'bin/**/*.js']
} This is not precisely possible with the current include implementation. |
the two use-cases that I'd like to solve are:
I wonder what the most elegant approach to solve this is. |
Right, I think what I suggested before: var defaults = {
include: everything,
exclude: node_modules_and_common_test_paths
}; Our algorithm for matching is: var fileMatches = includes.matches(file) && !excludes.matches(file)
@bcoe, I think this method gives you the best answer to your request:
Just add a glob for that file to
Just add that file to |
@jamestalmage I am sold \o/ |
@jamestalmage I think this is ready to land, I've tested thoroughly at this point. |
Sorry for the last minute comment. Please bear with me, but I would like to air out my thoughts. I see files being loaded in two distinct modes right now (prior to 3db354b):
In the default mode, include and exclude are only working against a very limited set of files. In the second mode, all files that are not explicitly excluded are included. I was thinking that include can instead replace the This way include can specifically add files that are not required. Does that make sense? Or is that not the vision for include that you had in mind? |
@Lalem001 let's open a discussion about |
@bcoe understood. Go for it |
glob-based include/exclude functionality
A few slight tweaks to Lalem001's awesome work on glob-based excludes:
micromatch
. This works with leading./
so that usingnpm link
does not break exclusions.include
along withexclude
.Reviewers: @Lalem001, @davidchase, @novemberborn