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:
@@ -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
|
||||
|
||||
@@ -169,7 +169,7 @@ func (g *defaultRpcGenerator) genCall() error {
|
||||
// if mockgen is already installed, it will generate code of gomock for shared files
|
||||
_, err = exec.LookPath("mockgen")
|
||||
if mockGenInstalled {
|
||||
execx.Run(fmt.Sprintf("go generate %s", filename))
|
||||
execx.Run(fmt.Sprintf("go generate %s", filename), "")
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
@@ -74,7 +74,7 @@ func (g *defaultRpcGenerator) genPb() error {
|
||||
func (g *defaultRpcGenerator) protocGenGo(target string) error {
|
||||
src := filepath.Dir(g.Ctx.ProtoFileSrc)
|
||||
sh := fmt.Sprintf(`protoc -I=%s --go_out=plugins=grpc:%s %s`, src, target, g.Ctx.ProtoFileSrc)
|
||||
stdout, err := execx.Run(sh)
|
||||
stdout, err := execx.Run(sh, "")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user