1
0
mirror of https://github.com/go-task/task.git synced 2025-06-17 00:17:51 +02:00

fix: special variable type errors in vars with no task context (#2107)

* fix: stop dotenv trying to fetch variables when no dotenv specified

* fix: set special variables to "" when they can't be calculated
This commit is contained in:
Pete Davison
2025-03-10 11:46:07 +00:00
committed by GitHub
parent 6ee1053c96
commit 6604b9a8cc
3 changed files with 11 additions and 4 deletions

View File

@ -209,9 +209,16 @@ func (c *Compiler) getSpecialVars(t *ast.Task, call *Call) (map[string]string, e
allVars["TASK_DIR"] = filepathext.SmartJoin(c.Dir, t.Dir)
allVars["TASKFILE"] = t.Location.Taskfile
allVars["TASKFILE_DIR"] = filepath.Dir(t.Location.Taskfile)
} else {
allVars["TASK"] = ""
allVars["TASK_DIR"] = ""
allVars["TASKFILE"] = ""
allVars["TASKFILE_DIR"] = ""
}
if call != nil {
allVars["ALIAS"] = call.Task
} else {
allVars["ALIAS"] = ""
}
return allVars, nil