-
-
Notifications
You must be signed in to change notification settings - Fork 40
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 findUpMultiple()
method
#27
Comments
I think you will find the discussion in #19 to be helpful. In short: we plan to implement #21 instead and then you can write your own accumulator function that decides when to stop. See the example code in the linked issues for how it would be used. I'm going to close this, since that should solve your use case quite well. Would love to hear your thoughts, though! I will set aside some time over the weekend to get this done. Seems like a lot of people need it. |
Okay, guess it's time that I write my own implementation then. |
Even with #21, I think these options would be useful as high-level options for the common-case. The The |
There was already a PR to add the IMO the function approach is fairly elegant for this use case. Let me try to clarify with a usage example. Below, I create a list of const stopDir = path.resolve('abcd');
const matchingFiles = [];
await findUp((dir) => {
const filePath = path.join(dir, 'package.json');
if (fs.existsSync(filePath)) {
matchingFiles.push(filePath);
}
return dir === stopDir;
}); |
How about |
@sholladay even if it can be done with a function argument, I'd say this is a pretty commonly needed option. I'd probably be willing to PR both if @sindresorhus approves. |
In case anyone comes here looking for this, I have implemented the function approach. You can use my branch for now until it's released (see PR #28). |
Even with #28, I still think these options would be useful. I don't think As for the |
I like |
Let's go with
Do you mean the array input? If so, that would be weird, as making |
Ah, right. I forgot these key words from the OP:
I've never needed anything like that. In my head, I was thinking that |
@IssueHunt has funded $60.00 to this issue.
|
This could potentially also be an option to just |
// @coreyfarrell In case you have any thoughts. |
For the ability to return an array of files I think a separate |
Regarding the initial request for a |
The |
Combining Anyways, I think we should have one issue per feature request, so I'd say we should open another for |
So in summary: It should be a Note: To get the bounty, you need to fix #49 too. |
@sindresorhus has rewarded $54.00 to @vast. See it on IssueHunt
|
I have a use case where I need to find all matching files in parent paths and I wonder if you would consider having a
multiple
option that causes the function to return a array of filepaths.I may also need to stop at a certain path (e.g. don't go all the way to root), so ahandled bystopat
option might also be nice to have.findUp.stop
.IssueHunt Summary
vast has been rewarded.
Backers (Total: $60.00)
Submitted pull Requests
findUpMultiple
Tips
The text was updated successfully, but these errors were encountered: