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

File Order "more precise pattern" seems buggy #16

Open
MichaelBailly opened this issue Apr 7, 2017 · 1 comment
Open

File Order "more precise pattern" seems buggy #16

MichaelBailly opened this issue Apr 7, 2017 · 1 comment

Comments

@MichaelBailly
Copy link

MichaelBailly commented Apr 7, 2017

Hello there,

I'm using your wonderful library and encountered a problem. We follow some style guide, and so we got test files in the same folders than library files. In order to match "everything that is not a test file", we use the pattern '**/!(*spec).js'. We also have one file that we absolutely need to have before the others.

So, taking back the layout of the README.md file, if you do a

var files = glob.sync([
  'files/b.txt',
  'files/**/!(*spec).txt'
]);

The library will answer:

[ 'files/a.txt',
  'files/b.txt',
  'files/c.txt',
  'files/x/y.txt'
  'files/x/z.txt' ]

Obviously b.txt is not on top. WDYT ?

Thanks, regards

@jpillora
Copy link
Owner

jpillora commented Apr 7, 2017

Thanks! Yes, that's right! It needs some smarts to better compare the precision of:
files/b.txt and files/**/!(*spec).txt. Currently, the latter – even with the *s removed – is longer than the former so it's treated as more precise. We could add logic, any pattern with ** in it is always "less precise" than others? Are you able to send a PR?

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

No branches or pull requests

2 participants