-
-
Notifications
You must be signed in to change notification settings - Fork 470
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
Sort Files with 'glob.sync' #372
Comments
If at all possible, I would expect glob to return files in the order specified in patterns. This is the way that *nix glob works, and I use it for precedence. Edit: It doesn't work this way. I'm not trying to answer OP, but rather agreeing. I'm currently working on a precedence filter for the results in my project -- I'm not sure how to fix it in this library. |
FYI, just to add some more detail here, the docs show that the matches are sorted unless the The code for this is in common.js, in the |
I could try adding |
@tarwich The reason bash does it that way is that bash is doing an iterative pattern replacement through the pattern string, rather than a recursive directory walk limited by the pattern. While that's very intuitive in a lot of cases, and easy to tie the results back to the pattern that they expanded into, it's also a bit challenging to do in an optimally performant way in JavaScript. As it happens, glob v9 takes it even further from doing bash pattern expansion, in order to maximize parallelism in the file system walk for performance, and avoid ever testing the same path whenever possible. So, you'll probably have to use some other mechanism for path precedence in the match results, I'm afraid. There's fundamentally no way to get the performance gains in v9 without ditching the string-expansion approach in favor of a recursive fs walk style approach. |
…he to third_party/ This is a 'Flip' CL from go/nodemodulesingoogle3. (The Flip CL does not need LGTM from third_party) LOCAL MODIFICATIONS: Sorting is no longer supported by glob.sync (isaacs/node-glob#372). GREEN TCP: OCL:605031371:BASE:606082614:1707691953923:1250eb85 PiperOrigin-RevId: 605031371
PiperOrigin-RevId: 605031371
PiperOrigin-RevId: 608689322
PiperOrigin-RevId: 608689322
PiperOrigin-RevId: 608689322
PiperOrigin-RevId: 608689322
PiperOrigin-RevId: 608689322
PiperOrigin-RevId: 608689322
PiperOrigin-RevId: 608689322
PiperOrigin-RevId: 611167691
PiperOrigin-RevId: 611167691
PiperOrigin-RevId: 611167691
PiperOrigin-RevId: 611167691
PiperOrigin-RevId: 611167691
PiperOrigin-RevId: 611167691
PiperOrigin-RevId: 611167691
I have some problems to sort the files. Glob.sync order the files alphabetically. Is there any solution to order my way?
I have:
glob.sync("./app/*(main|app).js")
I want to include 'main.js' first and later 'app.js', but actually, sync does the opposite. The first file that "match" is app.js due to the alphabetical order.
Any Solution?
Thanks in advance.
The text was updated successfully, but these errors were encountered: