Watching more than expected.
See original GitHub issueHi.
I’m using grunt-contrib-watch which is using gaze v1.1.1.
My Gruntfile.js has a watch
section in the config of:
watch: {
// build: {
// files: [
// 'src/**/*.*',
// 'third_party/**/*.*',
// 'vendor/**/*.*'
// ],
// tasks: [
// 'build',
// 'notify:build_complete'
// ]
// },
configFiles: {
cwd: '',
files: [
'bower.json',
'package.json',
'Gruntfile.js'
],
options: {
reload: true
},
tasks: [
'notify:watch_grunt'
]
}
}
If I add some simple debugging to grunt-contrib-watch/tasks/watch.js, just before the call to Gaze();
grunt.log.writeflags(patterns);
grunt.log.writeflags(target.options);
I get output of:
Flags: bower.json, package.json, Gruntfile.js
Flags: reload, target=null, cwd="C:\\wamp\\www\\epos", cliArgs=["-v"], interrupt=false, nospawn=false, spawn, atBegin=false, event=["all"]
which is exactly right for when I’m watching the config files.
The output I get next (provided by using -v
option) is:
Watching bower.json for changes.
Watching .git for changes.
Watching .idea for changes.
Watching config for changes.
Watching logs for changes.
Watching node_modules for changes.
Watching public for changes.
Watching scripts for changes.
Watching src for changes.
Watching temp for changes.
Watching test for changes.
Watching third_party for changes.
Watching vendor for changes.
Watching package.json for changes.
Watching Gruntfile.js for changes.
But I can’t get beyond this debugging as I don’t know how to output content without grunt! If someone can point me to some easy debugging tools/info, I’ll be happy to track this bug down.
If you were watching, you’ll notice the commented out build
section. If I use both sections, I still get the spurious entries. If I use ONLY the build
section, all is well, leading me to think that there something wrong when only files are being watched.
I tried excluding directories, using relative paths, etc. all to no avail.
configFiles: {
cwd: '',
files: [
'!*.*',
'!**/*.*',
'!**/',
'./bower.json',
'./package.json',
'./Gruntfile.js'
],
options: {
reload: true
},
tasks: [
'notify:watch_grunt'
]
}
``
Issue Analytics
- State:
- Created 7 years ago
- Comments:12 (3 by maintainers)
Top GitHub Comments
@rquadling @shama I investigated a little more on this, and I found something interesting.
In my root folder. Say I just have a test.js file that I want to watch. I adding it like this:
gaze("test.js", function(err, watcher) {}
When I check what file(s) it’s watching. In this case this files added to the watcher are:
Note I only requested to watch test.js file.
Just to check if it’s only watching one single file. I changed the content in a file inside on of the sub folders, and I’m now seeing this message in the console:
...was changed
Another strange things is there is no differene between star () and the globstar (*). A globstar adds sub dirs and files as well.
Example
/home/** would match /home/gus/data, but /home/* wouldn't.
In your module both * and * are equalent. See Glob wildcards regarding this and how it should work.
I also couldn’t find any options for
so maybe it adds hidden and dot files as well? And this took me to another issue, out of topics of this issue ticket. E.g. in native
fs.watch
you have apersistent
option. It’s not included with gaze
?I didn’t test this too much, but just scratched the surface of issues I found just now.
Update It does add dot files and dot directories by default.
This got auto-watched when gaze was detection changes when I was watching the test.js file mentioned above. Most of the time it only seem to list all folders and sub-folders and put their name in an array without watching the files inside it.
Making such huge array for nothing take a lot of resources, and why is it needed? What if I have 10k folders and watching one file in the root? The size of the array would be larger then what it can handle. I would either get a error telling me I’m running out of memory, or everything will slow down before it stops working.
@crazyhuggins Sounds good! Thanks and best of luck!