question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Watching more than expected.

See original GitHub issue

Hi.

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:open
  • Created 7 years ago
  • Comments:12 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
ghostcommented, Nov 14, 2016

@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:

  • 3 different files
  • 8 different folders

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

  • dot files
  • hidden files (same as dot files on some file systems)
  • file permissons
  • hidden folders
  • dot folders

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 a persistent 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.

 [ '.git\\',

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.

0reactions
shamacommented, Nov 14, 2016

@crazyhuggins Sounds good! Thanks and best of luck!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Next year, people will spend more time online than watching TV
In 2019, people are expected to spend an average of 170.6 minutes each day on online activities like watching videos on YouTube, sharing...
Read more >
Watch/Warning/Advisory Definitions - National Weather Service
Significant and hazardous winter weather is defined as a combination of: 1) 5 inches or more of snow/sleet within a 12-hour period or...
Read more >
Murphy's Laws - Cheap Thoughts
A carelessly planned project takes three times longer than expected; ... Success occurs when no one is looking, failure occurs when the General...
Read more >
From speed viewing to watching the end first: how streaming ...
Our findings show that streaming services have changed the way we watch television series, and that fans are much more active than expected...
Read more >
What the Club is watching Tuesday — more cooler inflation ...
After last week's cooler consumer price index, the October producer price index rose less than expected. Year over year, the PPI was up...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found