-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Ignore possible test files under node_modules folder. Fixes #226. #260
Conversation
// ignore all possible test files in node_modules folder | ||
files = files.filter(function (file) { | ||
return (file.indexOf('node_modules') === -1); | ||
}); |
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.
This is code is actually before matched files are found.
At this point, files
is not an actually a list of files, but a list of glob strings (like "**/*-test.js
).
You may be seeing results on your machine here because your operating system is automatically expanding glob strings for you (I believe that is the case on OSX, but not on Windows).
You are on the right track. You need to expand on this using my comments from above. You should also try to create a test or two. This will likely involve adding some files to the A good way to verify you have written an effective test is to get rid of your changes to the production code (keep your tests in place). Your new tests should fail without your changes (otherwise what was the point?!), then add back in your changes and verify your changes to the production code take you from failing tests to passing tests. Done this way, everybody can understand the need for the new code you propose, and your tests become a way of documenting the importance of your PR. |
@@ -201,6 +201,7 @@ function init(files) { | |||
function handlePaths(files) { | |||
if (files.length === 0) { | |||
files = [ | |||
'!node_modules', |
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.
I think we can use '!**/node_modules',
to match node_modules
at any level and not having to do the filtering below.
Wouldn't that only work if the user runs |
@sotojuan With how this is currently implemented, yes, but it would work if you instead just always pushed it as the last item to the |
Thanks, |
@sotojuan That's what I said ;) |
Ha, I meant adding the extra |
Right, yeah. |
👍 |
Landed. Very nice work @sotojuan ;) |
As noted in #226, this pull request does two things:
!node_modules
to the array https://github.com/sindresorhus/ava/blob/master/cli.js#L203, so that it ignores the folder when ava is ran with no arguments.node_modules
in it. This works in case the user does something likeava **
, which is rare but can happen.Perhaps there's a more efficient way to do this, but I have tested this in various cases and it works, though I haven't been able to write a proper test for it.
Thanks and let me know if there's anything I can improve on.