fix command run path bug (#52)

* rebase upstream

* rebase

* trim no need line

* trim no need line

* trim no need line

* optimized go path logic

Co-authored-by: kingxt <dream4kingxt@163.com>
This commit is contained in:
kingxt
2020-09-08 12:19:34 +08:00
committed by GitHub
parent ff7c14c6b6
commit 4408767981
5 changed files with 24 additions and 16 deletions

View File

@@ -8,7 +8,7 @@ import (
"runtime"
)
func Run(arg string) (string, error) {
func Run(arg string, dir string) (string, error) {
goos := runtime.GOOS
var cmd *exec.Cmd
switch goos {
@@ -19,7 +19,9 @@ func Run(arg string) (string, error) {
default:
return "", fmt.Errorf("unexpected os: %v", goos)
}
if len(dir) > 0 {
cmd.Dir = dir
}
dtsout := new(bytes.Buffer)
stderr := new(bytes.Buffer)
cmd.Stdout = dtsout