To be honest, I'm not sure if this is a bug or not. I've found it inconvenient behavior in my own use, so I've changed it in my local fork. Currently, when a nested directory is iterated over, the 'end' event is only called when all the root entries have loaded, meaning that it is impossible to know when all sub-entries are complete.
This patch requires that all sub-queries load before the root directory is to load. (There's a line in here, "tree.error" that I'm not sure I understand — right now the "end" event will not fire if this the case.)
Fix Loading Issue in lib/tree.js
This code fixes a bug whereby some tree elements will not yet
have loaded when the 'end' event is signalled.
Fix Loading Issue in lib/tree.js [Take Two]
Fix file path order bug.
HI @fatlotus, it seems logical that the end event should fire only when the full tree has been scanned. I've added a unit test that is currently failing, thus proving your observation. If you'd like to update your fork & run the tests to ensure your code causes it to pass, we can look at merging your PR.
Couldn't help it, I wrote the tests. Thanks for your contribution!