go-task / task

A task runner / simpler Make alternative written in Go
https://taskfile.dev
MIT License
11.01k stars 584 forks source link

Specify Taskfile location in environment variable. #1721

Open shpoont opened 1 month ago

shpoont commented 1 month ago

It would be great to have the option to set the path to the Taskfile using an environment variable. This would be particularly useful in scenarios where the Taskfile is not located in the default path (e.g., Taskfile.yaml), allowing us to avoid specifying the path each time.

trulede commented 1 month ago

You can do that and more with the shell:

$ export MYTASKFILE=foo.yaml
$ task --taskfile $MYTASKFILE
stat foo.yaml: no such file or directory
$ alias task='task --taskfile $MYTASKFILE'
$ task
stat foo.yaml: no such file or directory
$ alias task='task --taskfile ${MYTASKFILE:-Taskfile.yml}'
$ unset MYTASKFILE
$ task
stat Taskfile.yml: no such file or directory

More chance that it works too ... the internals of Task are not so easy.

shpoont commented 1 month ago

@trulede Thanks, but this is not what I am looking for. Your example would work with single instance of go-task usage. If it is used in multiple places, it would mean that you must find all occurrences of usage of go-task and rewrite them to support this approach which makes this hardly practical.