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 option to exclude files based on regular expression #86

Merged
merged 13 commits into from
Apr 16, 2018

Conversation

MarcelRobitaille
Copy link
Contributor

I wanted to exclude /node_modules/.

@MarcelRobitaille
Copy link
Contributor Author

Is this likely to get merged or should I publish a fork?

@xzyfer
Copy link
Owner

xzyfer commented Jun 27, 2017 via email

@MarcelRobitaille
Copy link
Contributor Author

Do you mind if I publish my fork on npm then?

@xzyfer
Copy link
Owner

xzyfer commented Jun 27, 2017

If you wish :)

@xzyfer
Copy link
Owner

xzyfer commented Jun 27, 2017

FWIW this implementation isn't complete. It's important to also do the exclusion when determine the ancestors and descendants. You'd also probably want to cache the regex check in the constructor to avoid doing it many times.

@MarcelRobitaille
Copy link
Contributor Author

I didn't want to check ancestors and descendants because I assumed the usual use case would be /node_modules/ and I wanted to keep things simple. To add the check to ancestors and descendants would it just be as simple as doing the same check in Graph.prototype.visitAncestors and Graph.prototype.visitDescendents?

What do you mean by caching the regex check? You mean this.exclude instanceof RegExp?

@MarcelRobitaille
Copy link
Contributor Author

Something like that?

@xzyfer
Copy link
Owner

xzyfer commented Jun 27, 2017

Not dealing with ancestors and descendants will mean that if a file imports a file from node_modules is appear in the dependency graph. This may be your intention but it's "surprising" and breaks the primary usecase of this library - the node-sass watcher.

@xzyfer
Copy link
Owner

xzyfer commented Jun 27, 2017

If files and/or directories are being excluded there should be no way for those exclude to appear in the graph.

@MarcelRobitaille
Copy link
Contributor Author

That makes sense. Is what I suggested the best way to do that?

@xzyfer
Copy link
Owner

xzyfer commented Jun 27, 2017

The regex caching is better. You'll still need to prevent exclude files being referenced in as ancestors and descendants.

@MarcelRobitaille
Copy link
Contributor Author

I'll write some tests I guess.

@xzyfer
Copy link
Owner

xzyfer commented Jun 28, 2017

Please remove package-lock.json

@MarcelRobitaille
Copy link
Contributor Author

Sure thing. BTW you should have write access, no?

@xzyfer
Copy link
Owner

xzyfer commented Jun 28, 2017

I do but I'm mostly catching up whilst in bed. Open source isn't my day job :)

@xzyfer
Copy link
Owner

xzyfer commented Jun 28, 2017

This is looking good, thanks for your time.

I have some performance concerns, but they can be address separately. I'll get this released in the next day or so.

readme.md Outdated
@@ -82,6 +82,13 @@ Default: `false`

Follow symbolic links.

#### excludes
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The option is exclude, not excludes

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops

@MarcelRobitaille
Copy link
Contributor Author

Yeah it's true that it checks a lot of regexes but idk how to avoid that.

@MarcelRobitaille
Copy link
Contributor Author

Any update on this?

@MarcelRobitaille
Copy link
Contributor Author

What are we waiting on? I'd like to make my fork after this has been merged.

@xzyfer
Copy link
Owner

xzyfer commented Apr 16, 2018

Thanks @Iambecomeroot. Apologies for the delay I've be occupied with other projects.

@xzyfer xzyfer merged commit 466faa8 into xzyfer:master Apr 16, 2018
nashiko pushed a commit to nashiko/js-graph-dependency that referenced this pull request Mar 24, 2022
* Add support for import globbing

* Add test for import globbing

* Update readme for import globbing option

* Forgot semis

* Fix spread on old node versions

* Add option to exclude files matching regex

* Remove changes made in other pr

I should probably have made a new branch for that...

* Cache RegExp check

* Check ancestors descendants

* I should run tests before pushing...

* Add tests

* Remove package-lock.json

* Fix typo in readme
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

Successfully merging this pull request may close these issues.

2 participants