mirror of
https://github.com/beego/bee.git
synced 2024-11-25 20:10:55 +00:00
Merge pull request #334 from amrfaissal/fix-beegen-output
Fix bee generate output in watch.go
This commit is contained in:
commit
0a58d03ca0
33
watch.go
33
watch.go
@ -120,8 +120,6 @@ func AutoBuild(files []string, isgenerate bool) {
|
|||||||
state.Lock()
|
state.Lock()
|
||||||
defer state.Unlock()
|
defer state.Unlock()
|
||||||
|
|
||||||
logger.Info("Start building...")
|
|
||||||
|
|
||||||
os.Chdir(currpath)
|
os.Chdir(currpath)
|
||||||
|
|
||||||
cmdName := "go"
|
cmdName := "go"
|
||||||
@ -129,7 +127,11 @@ func AutoBuild(files []string, isgenerate bool) {
|
|||||||
cmdName = "gopm"
|
cmdName = "gopm"
|
||||||
}
|
}
|
||||||
|
|
||||||
var err error
|
var (
|
||||||
|
err error
|
||||||
|
stderr bytes.Buffer
|
||||||
|
stdout bytes.Buffer
|
||||||
|
)
|
||||||
// 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 {
|
if conf.GoInstall {
|
||||||
@ -141,12 +143,11 @@ func AutoBuild(files []string, isgenerate bool) {
|
|||||||
}
|
}
|
||||||
if conf.Gopm.Install {
|
if conf.Gopm.Install {
|
||||||
icmd := exec.Command("go", "list", "./...")
|
icmd := exec.Command("go", "list", "./...")
|
||||||
buf := bytes.NewBuffer([]byte(""))
|
icmd.Stdout = &stdout
|
||||||
icmd.Stdout = buf
|
|
||||||
icmd.Env = append(os.Environ(), "GOGC=off")
|
icmd.Env = append(os.Environ(), "GOGC=off")
|
||||||
err = icmd.Run()
|
err = icmd.Run()
|
||||||
if err == nil {
|
if err == nil {
|
||||||
list := strings.Split(buf.String(), "\n")[1:]
|
list := strings.Split(stdout.String(), "\n")[1:]
|
||||||
for _, pkg := range list {
|
for _, pkg := range list {
|
||||||
if len(pkg) == 0 {
|
if len(pkg) == 0 {
|
||||||
continue
|
continue
|
||||||
@ -164,12 +165,15 @@ func AutoBuild(files []string, isgenerate bool) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if isgenerate {
|
if isgenerate {
|
||||||
|
logger.Info("Generating the docs...")
|
||||||
icmd := exec.Command("bee", "generate", "docs")
|
icmd := exec.Command("bee", "generate", "docs")
|
||||||
icmd.Env = append(os.Environ(), "GOGC=off")
|
icmd.Env = append(os.Environ(), "GOGC=off")
|
||||||
icmd.Stdout = os.Stdout
|
err = icmd.Run()
|
||||||
icmd.Stderr = os.Stderr
|
if err != nil {
|
||||||
icmd.Run()
|
logger.Errorf("Failed to generate the docs.")
|
||||||
logger.Info("============== Generate Docs ===================")
|
return
|
||||||
|
}
|
||||||
|
logger.Success("Docs generated!")
|
||||||
}
|
}
|
||||||
|
|
||||||
if err == nil {
|
if err == nil {
|
||||||
@ -187,15 +191,14 @@ func AutoBuild(files []string, isgenerate bool) {
|
|||||||
|
|
||||||
bcmd := exec.Command(cmdName, args...)
|
bcmd := exec.Command(cmdName, args...)
|
||||||
bcmd.Env = append(os.Environ(), "GOGC=off")
|
bcmd.Env = append(os.Environ(), "GOGC=off")
|
||||||
bcmd.Stdout = os.Stdout
|
bcmd.Stderr = &stderr
|
||||||
bcmd.Stderr = os.Stderr
|
|
||||||
err = bcmd.Run()
|
err = bcmd.Run()
|
||||||
}
|
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Error("============== Build Failed ===================")
|
logger.Errorf("Failed to build the application: %s", stderr.String())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
logger.Success("Built Successfully!")
|
logger.Success("Built Successfully!")
|
||||||
Restart(appname)
|
Restart(appname)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user