-
-
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
recursive option #24
recursive option #24
Conversation
I'm not sure if I have the necessary context to review this PR, but I'm wondering: for the use case you have presented (cpy), wouldn't it be viable to just append |
@UltCombo The results may be the same, the runtimes are not, e.g.: globby(['node_modules', '!node_modules'], {recursive: true})
// vs
globby(['node_modules{,/**}', '!node_modules{,/**}']) @sindresorhus, @UltCombo About the use cases: I'm struggling with myself: An alternative: // typeof(recursive): boolean or object
globby(['node_modules'], {
recursive: {
dot: true,
…
}
}) |
Note that negation globs are always And what I'm trying to say is, it would be nice if we could avoid adding so much complexity to this module. If the results are actually the same, and the perf is the same or better, I'd suggest to have the Apart from the complexity, another important point is that your code is instantiating a new glob object for each matched path, which likely adds a huge perf overhead to parse all these new generated glob patterns. Also, these new glob patterns are not sharing their caches (
Although the (lack of) cache is easy to fix, I believe it would still not be worth to spawn a new glob instance for each matched path. Perhaps it is worth trying to implement something like the Another general point about this feature: Did you consider "recursive" copies? I mean, copying a directory to a nested directory, e.g. if you copy the directory |
To be honest, I have only tested this: glob('node_modules', {ignore:[ 'node_modules' ]}, …)
// vs
glob('node_modules{,/**}', {ignore:[ 'node_modules{,/**}' ]}, …) The first one was more than 7 times faster than the second (in the
That is true, but I didn't came up with a better, readable idea - In addition, the nested
Thank you, yes I did. There are also some issues with mutually recursively linked directories to handle. Therefore I'm planning to determine the source files first, and starting to copy after. |
Well, that relative discrepancy is only useful when you pair it with the total execution time. If the total execution time is just some nano/microseconds, then it is perfectly normal that the second pattern takes a few microseconds more to be parsed into a regex by the underlying minimatch library. If the total execution times actually takes more than a few seconds, then it really means there is a perf issue with those patterns. |
You are very hard to convince, I like that - but I would not have wrote it, if it was negligible 😏 # install glob and some big dependencies like ava
$ time node -e "require('glob')('node_modules', {ignore:[ 'node_modules' ]}, console.log);"
null []
real 0m0.238s
user 0m0.200s
sys 0m0.028s
$ time node -e "require('glob')('node_modules{,/**}', {ignore:[ 'node_modules{,/**}' ]}, console.log);"
null []
real 0m4.020s
user 0m3.832s
sys 0m0.552s Apart from that, I think a |
Hahah yeah, I like to be throughout with my reviews. Furthermore, I'm currently working 11h+ a day, so I'm saving time by offloading the burden of proof to you. 😛 Indeed, looks like I'd like to see bench tests for Well, in any case, if you'd like to land this PR sooner, feel free to work with other reviewers here. 😉 |
You are right, |
Thank you, @UltCombo, you put me on the right track. It turned out that a |
Oh, nice! |
A
recursive
option for sindresorhus/cpy#10 (comment).The procedure would be as follows:
path
in the result, execute an additional glob:var paths = glob(path + '{,/**}', opts)
path
is a file, thenpaths
equals to[path]
path
is a directory, thenpaths
containspath
and all its files and folders with respect toopts
(especially:ignore
,dot
andfollow
)