From 0a6833e9d80d02376d4020f002894277f6d681ef Mon Sep 17 00:00:00 2001 From: Alexander Mancevice Date: Sat, 21 Aug 2021 07:20:33 -0400 Subject: [PATCH] Allow included Taskfiles to use ~/* paths --- taskfile/read/taskfile.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/taskfile/read/taskfile.go b/taskfile/read/taskfile.go index 780edd8e..8f3d2486 100644 --- a/taskfile/read/taskfile.go +++ b/taskfile/read/taskfile.go @@ -6,6 +6,7 @@ import ( "os" "path/filepath" "runtime" + "strings" "gopkg.in/yaml.v3" @@ -51,6 +52,12 @@ func Taskfile(dir string, entrypoint string) (*taskfile.Taskfile, error) { if filepath.IsAbs(includedTask.Taskfile) { path = includedTask.Taskfile + } else if strings.HasPrefix(includedTask.Taskfile, "~") { + home, err := os.UserHomeDir() + if err != nil { + return err + } + path = strings.Replace(includedTask.Taskfile, "~", home, 1) } else { path = filepath.Join(dir, includedTask.Taskfile) }