Skip to content

fix: ROOT_TASKFILE when Entrypoint is not set #1708

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion internal/compiler/compiler.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,10 +180,14 @@ func (c *Compiler) ResetCache() {
}

func (c *Compiler) getSpecialVars(t *ast.Task) (map[string]string, error) {
entrypoint := c.Entrypoint
if entrypoint == "" {
entrypoint = "Taskfile.yml"
Copy link
Member

@andreynering andreynering Jul 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, the default is not necessarily Taskfile.yml. We have a list of 8 possible file names that are detected and work by default:

defaultTaskfiles = []string{
"Taskfile.yml",
"taskfile.yml",
"Taskfile.yaml",
"taskfile.yaml",
"Taskfile.dist.yml",
"taskfile.dist.yml",
"Taskfile.dist.yaml",
"taskfile.dist.yaml",
}

In the taskfile package we have code that will try to detect it. It may be a bit tricky, but in order to be reliable we need to reuse that code somehow.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I totally agree I missed that part
What I did here, export taskfile.go in a new package in order to have access to DefaultTaskfiles
Then I check (as it's done on Exists func) if the file exist. I did not reuse the Exist function because we do not want to log smth

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I checked and it works with Taskfile.dist.yml

}
return map[string]string{
"TASK": t.Task,
"TASK_EXE": filepath.ToSlash(os.Args[0]),
"ROOT_TASKFILE": filepathext.SmartJoin(c.Dir, c.Entrypoint),
"ROOT_TASKFILE": filepathext.SmartJoin(c.Dir, entrypoint),
"ROOT_DIR": c.Dir,
"TASKFILE": t.Location.Taskfile,
"TASKFILE_DIR": filepath.Dir(t.Location.Taskfile),
Expand Down
Loading