1
0
mirror of https://github.com/go-task/task.git synced 2025-06-23 00:38:19 +02:00

expand home dir ("~" symbol) on paths

fixes #74
This commit is contained in:
Andrey Nering
2017-11-02 10:25:50 -02:00
parent f4216dd67f
commit baac067a1a
7 changed files with 196 additions and 5 deletions

View File

@ -12,6 +12,7 @@ import (
"github.com/go-task/task/internal/execext"
"github.com/Masterminds/sprig"
"github.com/mitchellh/go-homedir"
)
var (
@ -202,12 +203,11 @@ func (e *Executor) CompiledTask(call Call) (*Task, error) {
return nil, &taskNotFoundError{call.Task}
}
var r varReplacer
if vars, err := e.getVariables(call); err == nil {
r.vars = vars
} else {
vars, err := e.getVariables(call)
if err != nil {
return nil, err
}
r := varReplacer{vars: vars}
new := Task{
Task: origTask.Task,
@ -221,6 +221,10 @@ func (e *Executor) CompiledTask(call Call) (*Task, error) {
Silent: origTask.Silent,
Method: r.replace(origTask.Method),
}
new.Dir, err = homedir.Expand(new.Dir)
if err != nil {
return nil, err
}
if e.Dir != "" && !filepath.IsAbs(new.Dir) {
new.Dir = filepath.Join(e.Dir, new.Dir)
}