1
0
mirror of https://github.com/go-task/task.git synced 2025-06-25 00:47:04 +02:00

Little refactor on command creation

This commit is contained in:
Andrey Nering
2017-03-12 17:18:59 -03:00
parent 678ea86350
commit 8c5e7e89cd
5 changed files with 62 additions and 28 deletions

View File

@ -6,11 +6,12 @@ import (
"errors"
"io/ioutil"
"os"
"os/exec"
"runtime"
"strings"
"text/template"
"github.com/go-task/task/execext"
"github.com/BurntSushi/toml"
"gopkg.in/yaml.v2"
)
@ -31,12 +32,7 @@ func handleDynamicVariableContent(value string) (string, error) {
if result, ok := varCmds[value]; ok {
return result, nil
}
var cmd *exec.Cmd
if ShExists {
cmd = exec.Command(ShPath, "-c", value[1:])
} else {
cmd = exec.Command("cmd", "/C", value[1:])
}
cmd := execext.NewCommand(value[1:])
cmd.Stdin = os.Stdin
cmd.Stderr = os.Stderr
b, err := cmd.Output()
@ -83,7 +79,7 @@ func (t *Task) handleVariables() (map[string]string, error) {
var templateFuncs = template.FuncMap{
"OS": func() string { return runtime.GOOS },
"ARCH": func() string { return runtime.GOARCH },
"IsSH": func() bool { return ShExists },
"IsSH": func() bool { return execext.ShExists },
}
// ReplaceVariables writes vars into initial string