You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello! It seems as though the ordering of results is non-deterministic, right?
Directories are looped over by node-glob asynchronously, thus files may be returned in any order, depending on which directories finish first.
the nosort flag is set to true when asking glob to return results
That's only a default that may be overridden on options. We do this because node-glob sorts results by default, and we don't want glob to perform extra unnecessary operations.
the aggregate result of glob calls seems to be constructed in the order they are returned, which is unpredictable
files.sort()
Edit: I hope that last line didn't seem snarky without a comment, I was in a rush and should have taken more time. I just wanted to make the point that .sort() is all you need to do to sort the results. There will never be a time when files are deterministic in a realistic scenario -- even when directories are looped over synchronously, since files and folders change. However, if you're just looking for determinism for unit tests or something, you should be able to simulate that by sorting the returned array. I had considered adding this feature, but honestly all we'd do is files.sort(). If consensus is that we should do it anyway, for parity, I'm totally fine with that and would accept a PR.
Hello! It seems as though the ordering of results is non-deterministic, right? This seems true to me, for two reasons:
nosort
flag is set totrue
when askingglob
to return results (https://github.com/jonschlinkert/matched/blob/master/lib/promise.js#L12)It this the intended behavior? If so, would you mind mentioning something about it in the docs? Thanks for this lib!
The text was updated successfully, but these errors were encountered: