-
-
Notifications
You must be signed in to change notification settings - Fork 133
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
Option to only return files #33
Comments
I'm neutral on this one. You have basically described Chokidar's matching behavior—when it matches a directory, all descendant files and directories are included. In Chokidar, you can set a Though, I'm not exactly sure how this approach is better than the current ones. To match all I may have not fully understood your suggestion. Can you post a sketch of how you think this API would look like and what problem is it solving (or is it actually just hiding the |
@UltCombo It's solving the problem that people specify directories in tools and expect it to work. Most people don't fully understand globs. I also want it to work that way.
Yes To be clear, this will be an opt-in option. Name |
@sindresorhus I see. I agree about the CLI friendliness. I'm just not sure if this should be handled in globby, in the caller or in a different package (my glob-manipulate package comes to mind). Regarding the name: |
@UltCombo I think it should be handled here. I made globby with the intention of making globbing more human friendly. This is fully in the scope of that. Lots of tools now have duplicated logic to handle this case already. Better have it done properly in one place. Lets go with |
Yeah, I fully agree on deduping this logic and doing it properly in a single place. To be clear, when I asked whether this should be handled in globby or in the caller, I'm also considering the possibility of globby or the caller including a dependency specifically for this glob manipulation task. globby is not the only node-glob abstraction, so implementing such glob manipulation tasks here mean that this work may be duplicated in other node-glob abstractions. I've created glob-manipulate to avoid such duplication. |
Sure, this sounds useful. |
If I have understood correctly,
I like the extension idea, but using globs seems more natural to me:
|
Most tools I've created process files only. |
@schnittstabil This would mean Maybe also support the following format: expandDirectories: {
files: ['test_*'],
extensions: ['js', 'jsx']
} What do you think about setting |
Shouldn't we instead add this option to glob? That way all this lib has to do is perform a union on the returned arrays, or memoize if we stream with Aside from that, a path to a dir means all files within, with no customization: cp -r /path/to/dir/ /dest/ is the same as: cp -r /path/to/dir/**/* /dest/ |
Preferably yes, but |
What part of glob moves too slow? |
The project, not the code. |
Oh, ok. Do you intend to rewrite glob and not depend on it? |
No, this can be implemented upon |
Currently,
globby
or ratherglob
returns both directories and files. You can turn off returning directories using thenodir: true
glob option, but that's not what you want. You'd rather want to expand directories into files. That's what this option should do. Soglobby.sync('foo')
wherefoo
is a directory would be expanded into all the files in that directory that doesn't match any of the ignore patterns. Same withglobby.sync('foo/**')
. There also needs to be a way to specify an array of extensions. In many cases you wouldn't want the expansion to happen for all files, but, for example, just.js
files. It should override thenodir
option if specified by the user.This would be useful and simplify code in AVA, XO, cpy, imagemin-cli, and other tools expecting files. For example: https://github.com/avajs/ava-files/blob/master/index.js#L212-L271
@UltCombo @schnittstabil @jamestalmage @SamVerschueren @novemberborn Thoughts?
The text was updated successfully, but these errors were encountered: