Skip to content
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

when multiple tasks watch the same path only one task runs #25

Closed
dylang opened this issue Dec 15, 2012 · 9 comments
Closed

when multiple tasks watch the same path only one task runs #25

dylang opened this issue Dec 15, 2012 · 9 comments
Milestone

Comments

@dylang
Copy link

dylang commented Dec 15, 2012

Lets say you have

watch:  {
            mocha: {
                files: ['lib/**/*.js'],
                tasks: ['mocha:all']
            },

            jshint: {
                files: ['lib/**/*.js'],
                tasks: ['jshint:all']
            }
}
grunt watch

When a change happens only the jshint task runs. It seems like the last task wins.

My expected behavior is that watch (or gaze) would notice the path already has a file watcher on it and just add another task on to run.

@shama
Copy link
Member

shama commented Dec 15, 2012

Hmm that is a fun problem because different targets could have overlapping watched files... so it might not be as simple as comparing matching patterns and grouping tasks.

Of course for your example above I'd say just make it one target but I get how this could be an issue for other configs. I'm not sure of the best way to solve this at this time.

@chrisirhc
Copy link

How about running it in the order of tasks that satisfies it?
This way, you can structure tasks such that you can control where they should fail.
One example would be to do unit tests before concat/deploy.

(Implementation detail: for.. in loop respects insertion order.)

@shama
Copy link
Member

shama commented May 2, 2013

Update: This needs to be fixed in shama/gaze#31 before it can happen here.

@jpommerening
Copy link

A coworker notified me of this behavior today. We use Gaze via grunt-regarde.

There are two regarde-tasks with partially overlapping file patterns, triggering different Grunt tasks. Here comes the interesting part:
The first time a changed file (in both sets) is detected, everything goes (more or less) as expected: Both tasks are executed sequentially and Running "regarde" task appears once after each task.
Only when I touch another file, the problem appears. In my case, only the second task runs; but it runs twice!

Looks like somewhere deep down a callback is overwritten?

@shama does that Test in shama/gaze#31 work?

Edit: Wait, how did I get here?

@shama
Copy link
Member

shama commented May 3, 2013

@jpommerening That test doesn't work but it should. I haven't tested it a bunch but we may only be able to open one descriptor per file. In which case I'll have to restructure gaze to achieve the desired behavior. Where instances access a single queue of changed files and trigger each instance upon matching (which sounds more efficient anyways).

doctyper added a commit to doctyper/grunt-contrib-watch that referenced this issue May 6, 2013
…ple tasks watch the same path only one task runs
@searls
Copy link

searls commented May 9, 2013

👍

I just ran into this while working on testdouble/lineman, because I'm trying to switch us back to grunt-contrib-watch. I'll take a look at @doctyper's PR

@mgol
Copy link
Contributor

mgol commented Jun 24, 2013

I see the issue: shama/gaze#31 has been fixed; can this bug be fixed, too, then? Thanks!

@searls
Copy link

searls commented Jun 29, 2013

Re: shama/gaze#31

Hey @shama, would you be able to test & bump the latest gaze? I'm eager to get https://github.com/testdouble/lineman back on track with the official watch task.

@searls
Copy link

searls commented Jul 12, 2013

Fantastic @shama! I look forward to the next version bump so I can start testing this with lineman.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
6 participants