-
-
Notifications
You must be signed in to change notification settings - Fork 41
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 ability to specify if looking for file or directory #33
Comments
This should be relatively easy to add and I've wanted it in the past, too. I'm +0.5 on it. Curious to see how Sindre feels about it. In the meantime, check out my branch that allows you to use a function to inspect filepaths as we walk up the tree: PR #28 Using that branch, you can do something like: const findUp = require('find-up');
const pathType = require('path-type');
(async () => {
const distPath = await findUp((dir) => {
return pathType.dir(path.join('dist')) && 'dist';
});
})(); ... and you can be sure that |
Yes, we need this. I'm thinking: |
Wouldn't this need to be implemented as a locate-path option? Assume someone calls One other question, what should happen if a symbolic link matches? Resolve with fs.realpath then retest the result? This could be a problem with using |
Yes
Yes, with an option to turn it off (?). ( |
|
@sholladay my idea is that in some cases callers might not want to ever match symlinks (regardless of what it points to). I've posted sindresorhus/locate-path#4 with a rough implementation plus a couple tests. |
Okay, thanks, that's helpful. Yeah, it might happen that someone needs it. 99% of the time, though, you can just treat a symlink as the thing that it points to. But I see what you're saying. 👍 |
@IssueHunt has funded $40.00 to this issue.
|
I'll submit a PR shortly to update package.json, testing and readme here. |
@sindresorhus has rewarded $36.00 to @coreyfarrell. See it on IssueHunt
|
Would be nice to be able to be able to specify in options if you are looking for a file or directory.
The text was updated successfully, but these errors were encountered: