1
0
mirror of https://github.com/beego/bee.git synced 2024-11-22 10:10:53 +00:00
This commit is contained in:
Unknown 2013-12-15 18:08:51 -05:00
parent cce4f8c289
commit 342172a1ac

View File

@ -15,6 +15,7 @@
package main package main
import ( import (
"bytes"
"fmt" "fmt"
"os" "os"
"os/exec" "os/exec"
@ -126,10 +127,24 @@ func Autobuild() {
// For applications use full import path like "github.com/.../.." // For applications use full import path like "github.com/.../.."
// are able to use "go install" to reduce build time. // are able to use "go install" to reduce build time.
if conf.GoInstall || conf.Gopm.Install { if conf.GoInstall || conf.Gopm.Install {
icmd := exec.Command(cmdName, "install") icmd := exec.Command("go", "list", "./...")
icmd.Stdout = os.Stdout buf := bytes.NewBuffer([]byte(""))
icmd.Stderr = os.Stderr icmd.Stdout = buf
err = icmd.Run() err = icmd.Run()
if err == nil {
list := strings.Split(buf.String(), "\n")[1:]
for _, pkg := range list {
if len(pkg) == 0 {
continue
}
fmt.Println(pkg)
icmd = exec.Command(cmdName, "install", pkg)
err = icmd.Run()
if err != nil {
break
}
}
}
} }
if err == nil { if err == nil {
@ -137,20 +152,11 @@ func Autobuild() {
if runtime.GOOS == "windows" { if runtime.GOOS == "windows" {
appName += ".exe" appName += ".exe"
} }
if isExist(appName) {
os.Remove(appName)
}
binPath := GetGOPATHs()[0] + "/bin/" + appName
if conf.GoInstall && isExist(binPath) { bcmd := exec.Command(cmdName, "build")
os.Rename(binPath, appName) bcmd.Stdout = os.Stdout
ColorLog("[INFO] Build command reduced\n") bcmd.Stderr = os.Stderr
} else { err = bcmd.Run()
bcmd := exec.Command(cmdName, "build")
bcmd.Stdout = os.Stdout
bcmd.Stderr = os.Stderr
err = bcmd.Run()
}
} }
if err != nil { if err != nil {
@ -164,11 +170,14 @@ func Autobuild() {
func Kill() { func Kill() {
defer func() { defer func() {
if e := recover(); e != nil { if e := recover(); e != nil {
fmt.Println("Kill -> ", e) fmt.Println("Kill.recover -> ", e)
} }
}() }()
if cmd != nil && cmd.Process != nil { if cmd != nil && cmd.Process != nil {
cmd.Process.Kill() err := cmd.Process.Kill()
if err != nil {
fmt.Println("Kill -> ", err)
}
} }
} }