We recently got bit by an unusual behavior in Task. When calculating dependencies, Task will re-run the same dependency if it's required by two separate tasks. See the previous link for a full example.
This bit us because we had two separate tasks that each depended on build:dev, and one wrapper task that combined the two separate commands into one. The result was that yarn was getting run twice, and in parallel. The yarn command would then sometimes conflict with itself, as one thread modified/deleted files that the other thread expected to be present.
This behavior of running dependent tasks multiple times can be solved a couple of ways, like putting run: once within each task that might be executed multiple times.
However, a simpler and less error-prone solution might be to specify run: once in the root of the Taskfile as suggested in that issue. That gives us a place to document what run: once does and why you would want it. Also, if you really had a place where you did want a dependent command to intentionally run multiple times, you can always specify run: always on that individual command.
IMO, this should be the default within the scaffold Taskfile.yml. And we should consider putting it at the top of every every individual task/*.yml file. Or maybe within each task would be better for that use-case. I would think it would be rare that you would want your SASS to compile twice or run Drupal's update hooks all within the same Task execution. But putting it in the default template seems like a no-brainer that won't impact any existing sites and prevent problems in the future.
We recently got bit by an unusual behavior in Task. When calculating dependencies, Task will re-run the same dependency if it's required by two separate tasks. See the previous link for a full example.
This bit us because we had two separate tasks that each depended on
build:dev
, and one wrapper task that combined the two separate commands into one. The result was thatyarn
was getting run twice, and in parallel. Theyarn
command would then sometimes conflict with itself, as one thread modified/deleted files that the other thread expected to be present.This behavior of running dependent tasks multiple times can be solved a couple of ways, like putting
run: once
within each task that might be executed multiple times.However, a simpler and less error-prone solution might be to specify
run: once
in the root of the Taskfile as suggested in that issue. That gives us a place to document whatrun: once
does and why you would want it. Also, if you really had a place where you did want a dependent command to intentionally run multiple times, you can always specifyrun: always
on that individual command.IMO, this should be the default within the scaffold Taskfile.yml. And we should consider putting it at the top of every every individual
task/*.yml
file. Or maybe within each task would be better for that use-case. I would think it would be rare that you would want your SASS to compile twice or run Drupal's update hooks all within the same Task execution. But putting it in the default template seems like a no-brainer that won't impact any existing sites and prevent problems in the future.