Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 support for path matcher function #28
Add support for path matcher function #28
Changes from 9 commits
95d4390
8b80cf1
e8072bb
44e67bf
102b688
7a83413
6ad0dd8
ca48c76
f858bdd
eff8479
cba6f26
af9d361
b10d5b2
eb97a2f
ae4d8bc
bb10d62
94fafd1
41b8bdb
cf3157c
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
You shouldn't mix async and sync. Here, it should have used an async method to check whether it exists. The problem is that
fs.exists
is deprecated, and it's also not async/await friendly. This is why I want to expose some utility methods. To make common operation simple.I'm thinking:
findUp.exists()
findUp.isFile()
findUp.isDirectory()
findUp.sync.exists()
findUp.sync.isFile()
findUp.sync.isDirectory()
I know this seems like a lot, but I want
find-up
to just work for people with minimal mental overhead or boilerplate.Maybe we don't need the
exists
methods as I can't really think of a scenario where you wouldn't care about the type. Can you?The methods could alternatively be passed into the callback as a sort of
context
or something. I think I prefer them to be on thefindUp
object though.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.
Or maybe we should have a
type
option that accepts eitherfile
ordirectory
, but defaults tofile
? Hmm, we should probably have that regardless, as currentlyfind-up
could match both directories and files, while most would only want to match file. Usually it's not a problem as people use extensions, but I can imagine a scenario where a user wants to find an extension-less file and instead gets a directory of the same name somewhere else in the hierarchy.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.
Yeah, I should've used
findUp.sync()
. I think I was trying to avoid that and then I realized:fs.exists()
is deprecated.fs
method.But now
fs.promises
is stable and it makes the examples simpler. How about something like this?That could replace the example below as well.
As for the utility methods, I agree they are useful and I'd also prefer for them to be properties on the
findUp
function. Let's do that. I think we should merge this PR first and then build the utilities on top of this functionality in a separate PR(s), since this is still useful with or without them.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 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 realized that if we implement #33, we don't need the file/directory checks, so we can simply implement two utility methods => #37