task icon indicating copy to clipboard operation
task copied to clipboard

fix: ROOT_TASKFILE when Entrypoint is not set

Open vmaerten opened this issue 1 year ago • 3 comments

fixes #1706

vmaerten avatar Jul 03 '24 11:07 vmaerten

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 avatar Jul 03 '24 11:07 vmaerten

@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.

pd93 avatar May 24 '25 13:05 pd93

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.

pd93 avatar May 24 '25 13:05 pd93