1
0
mirror of https://github.com/go-task/task.git synced 2025-03-19 21:17:46 +02:00

Allow included Taskfiles to use ~/* paths

This commit is contained in:
Alexander Mancevice 2021-08-21 07:20:33 -04:00
parent 50e5813222
commit 0a6833e9d8
No known key found for this signature in database
GPG Key ID: EEE46D60A89CAF4D

View File

@ -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)
}