-
Notifications
You must be signed in to change notification settings - Fork 167
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
Doesn't register new files added to a new directory #14
Comments
Yes this is something I totally want to support. Just haven't gotten to it yet. You've outlined the exact desired behavior. I'll start by adding some test cases for this on a new branch. |
Awesome, sounds good. |
Any news on this? Or do you want a PR? |
@thehydroimpulse Still on my radar. My wife and I just had a baby so I'm a bit behind on everything :). I have some unfinished work on this. I'm trying to move the file system diff stuff into a separate lib. I appreciate the offer for a PR though. Thanks! |
No worries. (Congratulations btw :)). |
@shama I have been thinking about this one and I want to throw out an idea to see if you are interested. What if gaze was changed to stop using fs.watch functionality and just do straight polling. I think this would greatly reduce the complexity required to maintain the file list. I created a quick example here to demonstrate the simplicity of a polling approach. Any interest? If so I can put together a PR. |
@rgaskill Polling is extremely inefficient. Watching many files using the polling technique will max out your CPU. Polling would work on a smaller file set but since gaze is targeting multiple use cases, I doubt that'd work. Also, doesn't gaze offer a polling only option? |
@thehydroimpulse The current implementation is already polling using the watchFile functionality. Your "max out your CPU" assertion is incorrect. Take a look at my prototype and let me know what you think. |
@rgaskill The CPU maxed out (on macs anyway) using |
Sorry for taking so long on this issue. I swear I'll get to it soon. @cowboy just released globule which I was hoping for to make this cleaner to implement. FWIW, the watch in Grunt v0.3 used a combination of polling and I benchmarked the difference awhile back so it may have changed. Using It would be nice to have as an option though. Take a look at #32. |
The current implementation of gaze uses fs.watch to watch directories to pickup on file additions and deletions and fs.watchFile to watch files for changes. I did this for reasons described in (#6 and #9). This issue (#14) is caused when a directory is added outside the the initial fileset found by the globing pattern (i.e. the directory created isn't under one of the directories being watched by fs.watch) but is within the globing pattern. The simplest process I can think of to find these additional directories outside the initial fileset found but still within the globing pattern is to re-scan for files using some globing tool (fileset, globule, etc..). This process is the most time consuming process of the entire watch process. For example if my globing pattern was /*/.js it would have to scan my entire hardrive to find all the js files which takes several minutes. The approach outlined in haze will perform equivalently (maybe a little better because it doesn't track directories) to the current approach except in addition it is doing the re-scan for files using the globing pattern. So, it is slower because of that extra globing pattern scan. One thought I have to avoid additional globing scans is to find the root directory of the globing pattern and fs.watch the root directory and all of it's subdirectories. Another plus to the haze approach is it's simplicity. There is no longer the process of having to tracking what you are watching and unwatching as files are deleted and added. Basically, it is just a set of filenames that are monitored for changes periodically and compared to a new set every cycle to find additions and deletions. There seems to be two points of discussion:
|
Just added this issue to fix the benchmarks: #33. Ideally it would be awesome to see the impact of each commit we make. Even more awesome if it could do it retroactively. That should aid in this research. I honestly don't care how files are watched just as long as tests pass in OSX, Linux and Windows and benchmarks prove improvement (which I hope to do better going forward). |
Can't wait to see this fixed. @shama Does your commit also add support for detecting changes to file names? |
@OliverJAsh I want to say yes but ill double check (and add a test). |
Is this in release? |
We also have a problem with being able to watch directories and would love to see this implemented. For example, no events are being fired when directory is being deleted floatdrop/gulp-watch#70. |
Say you are watching this pattern:
Assume this is the initial directory structure:
The following operations work:
But now say I add the folder
app/templates/snippets
, and then start adding files to that folder, so we end up with these files:Gaze won't send notifications that
snippets/a.handlebars
andsnippets/b.handlebars
were added/changed/deleted.You can fix this by modifying this code:
https://github.com/shama/gaze/blob/master/lib/gaze.js#L385-L408
I changed it to be this:
But, that isn't perfect yet b/c if you were to delete the folder
app/templates/users
, it would throw an error. Something along these lines though would be awesome.Gaze it seems could support such "smart" file watching, where even though
app/templates/snippets
doesn't minimatchapp/templates/**/*.handlebars
, it's contents might. This is the default behavior of FSEvents.Also, it seems like it should work where if you renamed or moved a directory, it would emit
deleted
for the old paths andadded
for the new paths for all the files in the nested directories.Thoughts?
The text was updated successfully, but these errors were encountered: