-
-
Notifications
You must be signed in to change notification settings - Fork 774
Description
Currently the dotenv key cannot be used inside included Taskfiles. Doing so gives the following error:
Included Taskfiles can't have dotenv declarations. Please, move the dotenv declaration to the main Taskfile
Suppose I have the below structure, where the root Taskfile includes the Taskfiles in the subdirectories:
.
├── app
│ └── Taskfile.yaml
├── deployment
│ └── Taskfile.yaml
└── Taskfile.yaml
I find it useful to be able to have the choice to run Task from either:
- the root directory, e.g.
task app:build, or - the
appsubdirectory, e.g.task build
I can't do this and also make use of the dotenv feature. If I place dotenv in the root Taskfile, it will be ignored in case 2. If I place dotenv in the included Taskfile, I get an error in case 1. I'd like dotenv declarations in included files to be processed without error. If the same .env file is referenced in multiple included Taskfiles, this should also not produce an error.
This does raise a question about order of precedence when different .env files are specified across different Taskfiles. Perhaps we could have a rule whereby values in a .env file override values from an included .env file. Or if it's simpler, just return an error if different Taskfiles reference different .env files.