task
task copied to clipboard
fix: ROOT_TASKFILE when Entrypoint is not set
fixes #1706
I thought put a default value here
entrypoint := flags.Entrypoint
if entrypoint == "" {
entrypoint = "Taskfile.yml"
}
but it would break
func getDefaultDir(entrypoint, dir string) string {
// If the entrypoint and dir are empty, we default the directory to the current working directory
if dir == "" {
if entrypoint == "" {
wd, err := os.Getwd()
if err != nil {
return ""
}
dir = wd
}
return dir
}
// If the directory is set, ensure it is an absolute path
var err error
dir, err = filepath.Abs(dir)
if err != nil {
return ""
}
return dir
}
I don't know which solution do you prefer
@vmaerten I just ran into this again while looking at #2267. Any chance you could rebase your changes? I think we should get this merged.
I just tested. Once rebased, you should be able to run this command:
task -t ./website/static/Taskfile.yml special-variables
ROOT_TASKFILE will evaluate to /path/to/task/website/static/website/static/Taskfile.yml which is definitely wrong. This appears to happen on main too.