-
-
Notifications
You must be signed in to change notification settings - Fork 624
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
fix: ROOT_TASKFILE when Entrypoint is not set #1708
base: main
Are you sure you want to change the base?
Conversation
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 |
internal/compiler/compiler.go
Outdated
@@ -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" |
There was a problem hiding this comment.
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:
Lines 19 to 28 in 88b0950
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
4a8c79c
to
0246192
Compare
0246192
to
2914609
Compare
fixes #1706