mirror of
https://github.com/beego/bee.git
synced 2024-11-22 05:00:54 +00:00
Add option go install
This commit is contained in:
parent
ead4f9fd81
commit
422e2dc737
1
bee.json
1
bee.json
@ -1,4 +1,5 @@
|
|||||||
{
|
{
|
||||||
|
"go_install": false,
|
||||||
"dir_structure":{
|
"dir_structure":{
|
||||||
"controllers": "",
|
"controllers": "",
|
||||||
"models": ""
|
"models": ""
|
||||||
|
3
run.go
3
run.go
@ -36,6 +36,8 @@ func init() {
|
|||||||
|
|
||||||
var appname string
|
var appname string
|
||||||
var conf struct {
|
var conf struct {
|
||||||
|
// Indicates whether execute "go install" before "go build".
|
||||||
|
GoInstall bool `json:"go_install"`
|
||||||
DirStruct struct {
|
DirStruct struct {
|
||||||
Controllers string
|
Controllers string
|
||||||
Models string
|
Models string
|
||||||
@ -71,6 +73,7 @@ func runApp(cmd *Command, args []string) {
|
|||||||
|
|
||||||
// loadConfig loads customized configuration.
|
// loadConfig loads customized configuration.
|
||||||
func loadConfig() error {
|
func loadConfig() error {
|
||||||
|
fmt.Println("[INFO] Detect bee.json")
|
||||||
f, err := os.Open("bee.json")
|
f, err := os.Open("bee.json")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// Use default.
|
// Use default.
|
||||||
|
15
watch.go
15
watch.go
@ -72,10 +72,23 @@ func Autobuild() {
|
|||||||
fmt.Println("[INFO] Start building...")
|
fmt.Println("[INFO] Start building...")
|
||||||
path, _ := os.Getwd()
|
path, _ := os.Getwd()
|
||||||
os.Chdir(path)
|
os.Chdir(path)
|
||||||
|
|
||||||
|
var err error
|
||||||
|
// For applications use full import path like "github.com/.../.."
|
||||||
|
// are able to use "go install" to reduce build time.
|
||||||
|
if conf.GoInstall {
|
||||||
|
icmd := exec.Command("go", "install")
|
||||||
|
icmd.Stdout = os.Stdout
|
||||||
|
icmd.Stderr = os.Stderr
|
||||||
|
err = icmd.Run()
|
||||||
|
}
|
||||||
|
|
||||||
|
if err == nil {
|
||||||
bcmd := exec.Command("go", "build")
|
bcmd := exec.Command("go", "build")
|
||||||
bcmd.Stdout = os.Stdout
|
bcmd.Stdout = os.Stdout
|
||||||
bcmd.Stderr = os.Stderr
|
bcmd.Stderr = os.Stderr
|
||||||
err := bcmd.Run()
|
err = bcmd.Run()
|
||||||
|
}
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println("[ERRO] ============== Build failed ===================")
|
fmt.Println("[ERRO] ============== Build failed ===================")
|
||||||
|
Loading…
Reference in New Issue
Block a user