Skip to content
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

WithFilesOnly GlobOption - Returns matching files, but not matching directories #79

Closed
djaglowski opened this issue Dec 13, 2022 · 3 comments
Assignees

Comments

@djaglowski
Copy link

Is it possible to configure Glob in such a way that it will return matching files but not matching directories?

For example, supposing that I have no knowledge of naming or structure, I just want to find all files immediately in the /var/log directory.

/var/log/some_file
/var/log/another_file
/var/log/some_dir/foo

If I specify the pattern /var/log/*, the result is [ "some_file", "another_file", "some_dir" ].

Is there a way to match only [ "some_file", "another_file" ]? If I'm understanding correctly, this is not currently possible. If that is the case, would you be open to adding a new GlobOption that specifies whether the result should include only files?

For context, this library is being used in the OpenTelemetry Collector, primarily for finding log files.

@bmatcuk
Copy link
Owner

bmatcuk commented Jan 2, 2023

Hey @djaglowski,

I've added a WithFilesOnly option in this PR - do you mind giving it a try to make sure it works before I merge it?

@djaglowski
Copy link
Author

djaglowski commented Jan 3, 2023

Hi @bmatcuk, Thanks for considering my request and putting together a PR so quickly. I've tested the changes here, and everything looks good to me.

@bmatcuk bmatcuk closed this as completed in 016ef08 Jan 4, 2023
@bmatcuk
Copy link
Owner

bmatcuk commented Jan 4, 2023

Awesome! I just released v4.5.0 with this PR merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants