-
Notifications
You must be signed in to change notification settings - Fork 131
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
replace fast-glob with custom fs.walk #1210
Conversation
Addresses purescript#1182 This implementation is using `micromatch` (a dependency of fast-glob) and `fs.walk` to traverse the file system itself, instead of relying on fast-glob. As opposed to the previous implementation (from purescript#1209) This implementation takes every .gitignore file into account, not just the root one. The callbacks `entryFilter` and `deepFilter` are used to control which directories to recurse into. When `entryFilter` encounters a .gitignore file, it's patterns are parsed into micromatch compatible ones and every subsequent call to these filter functions respect them. I'm not sure whether this should have been (partially) implemented in the registry-dev repo since that's where the FFI for fast-glob is located. I also did not remove the fast-glob npm dependency, since i'm not sure if it is still in use elsewhere and because the registry-dev dependency definitely still contains the foreign functions relying on it being available.
Wow - on my (very fast) machine the mainline Spago spends ~150ms crawling the filesystem for files, but with this patch that time is only ~10ms. That's a 1500% improvement I think? |
@Blugatroff the patch looks good! A few general notes:
The registry needs to check that paths are "sanitised", i.e. if they are self-contained in a directory, to make sure that if it's looking at some source contained in Spago might not have the same requirements, since things are definitely more local - while the registry has tighter security requirements, having to accept basically untrusted inputs.
As noted above, the requirements in spago might be different than the ones in the registry repo, so I'd say it's fine to have two separate implementations.
The |
Oh, and no worries about adding new tests - as long as the performance looks better and we don't break the expectations of the existing test suite then this is good to go |
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.
In fact, I'll go ahead and merge this - we can remove the unused packages in a followup patch. Thanks!
Addresses #1182
Description of the change
This implementation is using
micromatch
(a dependency of fast-glob) andfs.walk
to traverse the file system, instead of relying on fast-glob. As opposed to the previous implementation (from #1209) This implementation takes every .gitignore file into account, not just the root one. The callbacksentryFilter
anddeepFilter
are used to control which directories to recurse into. WhenentryFilter
encounters a .gitignore file, it's patterns are parsed into micromatch compatible ones and every subsequent call to these filter functions respects them.The previously used
Glob.match'
also returned two arrays one calledfailed
and one calledsucceeded
. I'm not sure what it means for a path to be in thefailed
array and this implementation does not have any equivalent. Because of that, this warning will no longer be emitted by spagoI'm not sure whether this should have been (partially) implemented in the registry-dev repo since that's where the FFI for fast-glob is located.
I also did not remove the fast-glob npm dependency, since i'm not sure if it is still in use elsewhere and because the registry-dev dependency definitely still contains the foreign functions relying on it being available.
Before i go any further and perhaps add tests, i wan't to get some feedback as to whether this is the right approach and place :)
Checklist:
README