gaze
gaze copied to clipboard
Test for creating file in subdirectories
Hi. Turns out, that if you have empty subfolder - it will not be watched by gaze. Steps for manual reproducing are in this issue.
Test in patch actually hangs, because add
event in not emitted.
This is a tricky one. Since the pattern **/*.js
doesn't initially match folder/subfolder
, the folder is not watched and therefore doesn't monitor valid added
events from within that folder.
Some options we have:
- Keep this behavior. If you want to get
added
events for unmatched folders, you need to specifically watch them. - Watch every potential folder. For the pattern
**/*.js
, we detect and watch all folders that match**/*
. This is pretty wasteful though and not full proof. - Utilize a different file watching mechanism, such as fsevent, either in tandem or instead of. This would require a bit of work to get working consistently.
- Another idea?
Option 2 sounds most like the "expected behaviour" to me. Perhaps make it opt-in to alleviate the wastefulness?
gaze('**/*.js', { matchEmptyDirs: true }, function() { });
I would like #2, with lukehorvat's suggestion if the wastefullness becomes an issue (this is happening in development environments, not production).
Option 2 sounds like the thing. You could use "!" in the glob to exclude specific subdirs.
I, too, would like to see the second option. It's rather impractical to use gulp tools such as gulp-watch without this functionality!
:+1: to see this merged.
:+1:
@demisx @artch this PR does not contains fix, so merging it will not solve this problem. Just to make it clear.
@floatdrop Sure. This :+1: meant to go for option 2 in @shama's post above.
I agree with @nmagerko - watching for new files should be considered an essential feature...
+1 especially annoying with gulp-watch
+1 for option 2. I would expect / to match any files that could ever potentially match that pattern.
@shama any progress on this? Can I help?
Thanks for the offer! All my focus right now is on getting https://github.com/shama/navelgazer integrated as it will make implementing option 2 above much easier and fix a number of other issues.
Testing and reporting issues on navelgazer would be much appreciated.
Since it's been a while since this was last updated, just curious if any progress has been made on handling new files/directories?
@brian428 Feel free to check out the navelgazer branch for progress. I'll be continuing to work on that branch until it's stable.
Although I think @floatdrop and eventually gulp are switching to chokidar. It uses fsevents which watches entire folder trees so it doesn't have this limitation. They've also just recently added file patterns. So definitely worth checking out if this issue is a big problem for you now.