Some tasks utilize the watch to trigger an event, ie: live reload. With Grunt
v0.3, those tasks on first run would create a variable, ie servers
. Then
subsequently ran by the watch task would check if the variable exists and then
use it. Since the new watch spawns tasks, this is no longer possible.
- Tasks would only have to be ran once (less configuration)
- Could also solve the common request for a task to know which files have been modified
- Simple to implement
- Watch task isn't as generalized as tasks now rely directly on the watch task
A demo of this is here albeit not exactly what @cowboy proposed. When the watch runs the child, the child can inform the parent, ie: okay now reload.
- Operates very similiarly to previous functionality (requiring minimal changes from tasks authors)
- Keeps the watch generalized. Only relies on the watch to run the child task
- Relies on opening another port
- A bit complicated and could lead to unforseen issues
- Not that speedy on Windows
- Allows the watch task to run like [email protected] requiring 0 changes from plugin authors
- Could get a list of impacted files
- Tasks rely on a user setting a watch config to work
- Tasks fail in ways Grunt can't stop. One task failure can kill the entire watch
- Tasks step on each other as they are in the same context. For test runners this is bad.
First runs the parent
and the watch runs the child
. The child communicates
with the parent by writing to a file or database.
- Task only relies on the watch to run tasks
- A lot of configuration required
So tasks could know they've been spawned by the watch by checking, ie:
grunt.option('spawned-by-watch');
- Easy to implement
- Watch task isnt as generalized as tasks now rely on this being done by the watch
- Child task still doesn't have access to communicate with parent
Emit events and allow watch to be configured to run under the same context
Some comments:
A - Cons: not sure of what you meant. Actually
watch
task is generalized: the tasks depending onwatch
are potentially not generalizedB- I'm not a Windows expert, but older version of Windows were not really speedy when you had to spawn processes ... Could also be a cons.
C - Pros: could also allow to get the list of impacted files
What about doing a mix of the solutions (e.g. solution G):