From 49fe9b7d03a213b3df34c45ea5fa085951ae6e5c Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Wed, 13 Nov 2013 09:34:37 +0800 Subject: [PATCH] change run command use execCommand method --- cmd/run.go | 31 ++++--------------------------- 1 file changed, 4 insertions(+), 27 deletions(-) diff --git a/cmd/run.go b/cmd/run.go index 88764eea0..35ec21993 100644 --- a/cmd/run.go +++ b/cmd/run.go @@ -15,13 +15,7 @@ package cmd import ( - "fmt" - "go/build" - "os" - "os/exec" - "github.com/codegangsta/cli" - "github.com/gpmgo/gopm/log" ) @@ -36,32 +30,15 @@ gopm run `, } func runRun(ctx *cli.Context) { - gopath := build.Default.GOPATH - genNewGoPath(ctx) + log.Trace("Running...") + cmdArgs := []string{"go", "run"} cmdArgs = append(cmdArgs, ctx.Args()...) - bCmd := exec.Command(cmdArgs[0], cmdArgs[1:]...) - bCmd.Stdout = os.Stdout - bCmd.Stderr = os.Stderr - - log.Log("===== application outputs start =====\n") - - err := bCmd.Run() - - fmt.Println() - log.Log("====== application outputs end ======") - - if err != nil { - log.Error("Run", "Fail to execute") - log.Fatal("", err.Error()) - } - - log.Trace("Set back GOPATH=%s", gopath) - err = os.Setenv("GOPATH", gopath) + err := execCmd(newGoPath, newCurPath, cmdArgs...) if err != nil { - log.Error("Run", "Fail to set back GOPATH") + log.Error("Run", "Fail to run program") log.Fatal("", err.Error()) }