task-keeper icon indicating copy to clipboard operation
task-keeper copied to clipboard

Runs multiple tasks if they have the same name

Open tennox opened this issue 2 years ago • 4 comments

If I have a task dev in e.g. package.json & Taskfile.yaml, it will run both. This is undesirable for me (and I feel like it used to be different?), as I often define tasks in both places, but the Taskfile would e.g. have pnpm install as dependency, and then run the pnpm run dev task (from package.json).

I don't see a clear way to define precedence between the task managers (config file / Env var TK_PREFER_MANAGERS?), but for this to be useful to me it would need something to change :thinking:

tennox avatar Jan 17 '24 16:01 tennox

It's some some hard to fix this problem, and you can use tk --runner=task hello to task in Taskfile.yaml. I will think about it and find a good solution to fix this problem.

linux-china avatar Jan 23 '24 15:01 linux-china

I'd propose:

  • a 'sensible' default order, e.g.
    • (generic first) Taskfile, justfile, Makefile, Procfile, ..
    • (lang-specific) npm, cargo, maven, composer, ...
    • (fallback) readme, ..?
  • and an environment variable TASKKEEPER_PRECEDENCE, that can:
    • give any runner precedence: task
    • give multiple runners precedence, while also defining order: task,just
  • (optional idea) --all to run tasks of all runners (akin to current behaviour)
  • (optional idea) TASKKEEPER_DISFAVOR, that marks runners as "only use if no other one is available" - I'm not sure this is needed (don't see a use-case), but could be an option for later in case it does become neede

tennox avatar May 09 '24 15:05 tennox

How about following flow:

image

linux-china avatar May 11 '24 09:05 linux-china

How about following flow

Looks about right... I do agree with putting Readme in the generic category as I've learnt it does require to specifically mark a readme code fence as a task. One thing I'm a bit unclear about though: what do you mean by alphabet: a-z ? I don't think the lexical order should have anything to do with selection..?

Also, just in case you were planning to put the diagram in the readme - it doesn't clearly state what happens if neither --all nor --runner are given - the arrow might benefit from a description "Select first by precedence", and positioning the env var descriptions related to that, not next to "all runners" flow - but this does not matter too much imo, just my two cents :tipping_hand_man:

tennox avatar May 12 '24 19:05 tennox