task
task copied to clipboard
How to force task but not its dependencies
Hello,
I'm working on developing a task and I'd like to re-run just it even it's up to date, but I don't want its dependencies to run because they take long time to run and I already know they are correct.
Is there a way to force running just particular task and skip its dependencies other than commenting "deps" for this task in Taskfile?
Hi @sheerun,
Today this still isn't possible, unless you edit the Taskfile as you said.
Maybe you could achieve that by refactoring your Taskfile. For example, having two tasks, one with deps and the other without. To share the code, you could have a third one that would be called by these two using task: foo
.
(Not sure how much sense it makes since I don't know what you're trying to do).
Regarding allowing forcing a single task, we could add another flag for that (e.g. --force-task=foo
as an alternative to --force
). Does that makes sense?
I think --force
should force only explicitly listed tasks. For example if there are tasks A, B, C and A depends on B and B depends on C, then task A --force
should force only task A and do B, C only if necessary, task A B --force
should force tasks A, B and perform C if necessary. Maybe this could be on v3 wishlist :)
If you do task A B C
as described above, A->B->C
, B->C
, and C
are started in parallel so that C is potentially run three times, B two times, and A once.
Just stating how it currently works.
In my example above the dependency is just A->B->C
, sorry if wasn't clear enough
As for your example, running C 3 times is something to be improved as well for v3, IMO..
@sheerun
I think --force should force only explicitly listed tasks.
That's a good point. But it's also a breaking change. And I'm sure there're users out there that'd expect that to work exactly how it works today: --force
forces everything.
So ideally, we have to find a way to make both use cases possible.
As for your example, running C 3 times is something to be improved as well for v3, IMO..
There's a jurassic issue for that already: https://github.com/go-task/task/issues/53. That discussion is old, so don't expect our opinions to be the same nowadays. But sure, we should look into fixing that.
I'm curious how you know the dependencies are up to date? Can you encode that information in the status
of those dependencies?
Closing in favor of #1200.
@sheerun @smyrman and any others who have upvoted this issue. Just pinging to let you know that #1200 (the experiment that adds the functionality described here) is now in a period for final comments/adjustments before it is marked as stable ahead of a future major release.
Please do give it a try and let us know if you have any feedback/comments. Once this is marked as stable, it will be very unlikely to change again.