|
|
@ -1,6 +1,7 @@ |
|
|
|
package cmd |
|
|
|
package cmd |
|
|
|
|
|
|
|
|
|
|
|
import ( |
|
|
|
import ( |
|
|
|
|
|
|
|
"fmt" |
|
|
|
"go/build" |
|
|
|
"go/build" |
|
|
|
"os" |
|
|
|
"os" |
|
|
|
"os/exec" |
|
|
|
"os/exec" |
|
|
@ -110,44 +111,54 @@ var newGoPath string |
|
|
|
func execCmd(gopath, curPath string, args ...string) error { |
|
|
|
func execCmd(gopath, curPath string, args ...string) error { |
|
|
|
cwd, err := os.Getwd() |
|
|
|
cwd, err := os.Getwd() |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
return err |
|
|
|
log.Error("", "Fail to get work directory") |
|
|
|
|
|
|
|
log.Fatal("", err.Error()) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
com.ColorLog("[INFO] change current dir from %v to %v\n", cwd, curPath) |
|
|
|
log.Log("Changing work directory to %s", curPath) |
|
|
|
err = os.Chdir(filepath.Join(cwd, "vendor")) |
|
|
|
|
|
|
|
if err != nil { |
|
|
|
|
|
|
|
com.ColorLog("[ERRO] change current directory error %v\n", err) |
|
|
|
|
|
|
|
return err |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
err = os.Chdir(curPath) |
|
|
|
err = os.Chdir(curPath) |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
com.ColorLog("[ERRO] change current directory error %v\n", err) |
|
|
|
log.Error("", "Fail to change work directory") |
|
|
|
return err |
|
|
|
log.Fatal("", err.Error()) |
|
|
|
} |
|
|
|
} |
|
|
|
defer os.Chdir(cwd) |
|
|
|
defer func() { |
|
|
|
|
|
|
|
log.Log("Changing work directory back to %s", cwd) |
|
|
|
|
|
|
|
os.Chdir(cwd) |
|
|
|
|
|
|
|
}() |
|
|
|
|
|
|
|
|
|
|
|
ccmd := exec.Command("cd", curPath) |
|
|
|
ccmd := exec.Command("cd", curPath) |
|
|
|
ccmd.Stdout = os.Stdout |
|
|
|
ccmd.Stdout = os.Stdout |
|
|
|
ccmd.Stderr = os.Stderr |
|
|
|
ccmd.Stderr = os.Stderr |
|
|
|
err = ccmd.Run() |
|
|
|
err = ccmd.Run() |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
com.ColorLog("[ERRO] change current directory error %v\n", err) |
|
|
|
log.Error("", "Fail to change work directory") |
|
|
|
return err |
|
|
|
log.Fatal("", err.Error()) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
oldGoPath := os.Getenv("GOPATH") |
|
|
|
oldGoPath := os.Getenv("GOPATH") |
|
|
|
com.ColorLog("[TRAC] set GOPATH from %v to %v\n", oldGoPath, gopath) |
|
|
|
log.Log("Setting GOPATH to %s", gopath) |
|
|
|
|
|
|
|
|
|
|
|
err = os.Setenv("GOPATH", gopath) |
|
|
|
err = os.Setenv("GOPATH", gopath) |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
com.ColorLog("[ERRO] %v\n", err) |
|
|
|
log.Error("", "Fail to setting GOPATH") |
|
|
|
return err |
|
|
|
log.Fatal("", err.Error()) |
|
|
|
} |
|
|
|
} |
|
|
|
defer os.Setenv("GOPATH", oldGoPath) |
|
|
|
defer func() { |
|
|
|
|
|
|
|
log.Log("Setting GOPATH back to %s", oldGoPath) |
|
|
|
|
|
|
|
os.Setenv("GOPATH", oldGoPath) |
|
|
|
|
|
|
|
}() |
|
|
|
|
|
|
|
|
|
|
|
cmd := exec.Command(args[0], args[1:]...) |
|
|
|
cmd := exec.Command(args[0], args[1:]...) |
|
|
|
cmd.Stdout = os.Stdout |
|
|
|
cmd.Stdout = os.Stdout |
|
|
|
cmd.Stderr = os.Stderr |
|
|
|
cmd.Stderr = os.Stderr |
|
|
|
return cmd.Run() |
|
|
|
|
|
|
|
|
|
|
|
log.Log("===== application outputs start =====\n") |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
err = cmd.Run() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fmt.Println() |
|
|
|
|
|
|
|
log.Log("====== application outputs end ======") |
|
|
|
|
|
|
|
return err |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func genNewGoPath(ctx *cli.Context) { |
|
|
|
func genNewGoPath(ctx *cli.Context) { |
|
|
|