1
0
mirror of https://github.com/go-task/task.git synced 2025-01-20 04:59:37 +02:00

Fix failing test

There was some breaking changes described at
https://github.com/mvdan/sh/issues/335#issuecomment-447605295
This commit is contained in:
Andrey Nering 2018-12-24 15:19:53 -02:00
parent 9361dbc39e
commit 57a01aa6ff
3 changed files with 19 additions and 5 deletions

View File

@ -9,6 +9,7 @@ import (
"mvdan.cc/sh/expand"
"mvdan.cc/sh/interp"
"mvdan.cc/sh/shell"
"mvdan.cc/sh/syntax"
)
@ -67,3 +68,16 @@ func IsExitError(err error) bool {
return false
}
}
// Expand is a helper to mvdan.cc/shell.Fields that returns the first field
// if available.
func Expand(s string) (string, error) {
fields, err := shell.Fields(s, nil)
if err != nil {
return "", err
}
if len(fields) > 0 {
return fields[0], nil
}
return "", nil
}

View File

@ -4,8 +4,9 @@ import (
"path/filepath"
"sort"
"github.com/go-task/task/v2/internal/execext"
"github.com/mattn/go-zglob"
"mvdan.cc/sh/shell"
)
func glob(dir string, globs []string) (files []string, err error) {
@ -13,7 +14,7 @@ func glob(dir string, globs []string) (files []string, err error) {
if !filepath.IsAbs(g) {
g = filepath.Join(dir, g)
}
g, err = shell.Expand(g, nil)
g, err = execext.Expand(g)
if err != nil {
return nil, err
}

View File

@ -3,10 +3,9 @@ package task
import (
"path/filepath"
"github.com/go-task/task/v2/internal/execext"
"github.com/go-task/task/v2/internal/taskfile"
"github.com/go-task/task/v2/internal/templater"
"mvdan.cc/sh/shell"
)
// CompiledTask returns a copy of a task, but replacing variables in almost all
@ -37,7 +36,7 @@ func (e *Executor) CompiledTask(call taskfile.Call) (*taskfile.Task, error) {
Prefix: r.Replace(origTask.Prefix),
IgnoreError: origTask.IgnoreError,
}
new.Dir, err = shell.Expand(new.Dir, nil)
new.Dir, err = execext.Expand(new.Dir)
if err != nil {
return nil, err
}