-
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
does not watch files if directory is empty #177
Comments
+1 |
2 similar comments
+1 |
+1 |
+1 This is correct. Even if the directory is not empty but does not contain matching files it will not trigger the add. It seems the root problem is if there is nothing that matches the glob at the time it starts watching it will not detect new files. |
+1 |
Would an acceptable answer be to have a hotkey and/or timer based way of reloading the watch? Much like automatic download messages, we could put a notification in the watch message if changes are unseen. (You have seen them on the web, "If the download doesn't start, click here." or "You are being redirected to the new xyz.com homepage, if not click here." Well, people could be prompted from the command line, if your changes aren't being detected press Ctrl + Alt + g for (if (gaze running) { stop gaze }; start gaze)... |
Has anyone figured out the cause of this bug? |
Ran into this now. Still a PITA issue 1 year later. |
I've encountered the same issue and I've found kind of a trick to get the job done. Being new in node and not a master in javascript, I've looked at the code and try to understand it's flow. Then I've noticed something strange here (in helper.js):
This function (called into the _addToWatched function among others), will always return false (into _addToWatched()) because the dir path that is passed to the function is resolved by the path module which never add a separator at the end of a directory path ... Maybe it would be better this way?
I know that's not perfect but personnaly I never put a dot in my directories names. Anyway, I tried some configurations to watch new files in empty dir and it would seem that if you ask to watch the dir and the dir files, it's ok. e.g: if you want to watch js source files in js/src but with src as an empty dir, doing that:
And the new files in src will be watched. |
@Xarksass nice detective work. I do think the "." as a delimiter is not a complete solution. I have and run into directories with that character a few times a year owing to Linux people not being adverse to doing that it seems-- still would be an improvement as the subset would go from all empty directories --> empty directories that contain a '.' . Would "return endpath.split('.').length > 0" work? |
Thanks. In my case, I don't think I'll encounter a dir with a dot but I'll keep thinking about a better solution. However, no "return endpath.split('.').length > 0" wouldn't work because it will always return true if there is at least one character in your string. |
Your reply makes me want to find a more effective solution so ... Add "var fs = require('fs');" (just before "var path = ..." for example). Then replace
By
The more I learn about Node, the more I love using it ;) |
this also causes a bug in grunt-contrib-watch: gruntjs/grunt-contrib-watch#282 |
When watching path/*.txt all works fine as long as there is at least one *.txt file present. If there are none, then 'added' is not triggered!
The text was updated successfully, but these errors were encountered: