Fix to #508, #494...: some grunt tasks not triggered when spawn:false #509
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The issues described in the #508, #494 and some others, occur when spawn is set to false.
In that case, the watchers are deleted and then re-created once the triggered tasks have completed their execution.
The re-creation of the watchers is a good idea, since this makes sure to take into account any change that could have happened in the file system (e.g. new repositories) or in the watch options while the triggered tasks were run.
However, when the triggered tasks make some changes to the watched files, it might happen that the changes are not detected because they happen just between the time the watchers are deleted and the time the new watchers are created: at the exact moment the changes are done to the file system, there is no watcher listening to the change. Hence, watch doesn't trigger tasks.
The fix consists in doing the deletion of the previous watchers once the watchers have been recreated. This way, there is always at least one watcher listening to file system changes.