build fix

This commit is contained in:
alessio 2016-08-03 16:46:36 +02:00
parent 117c3a0726
commit 982999e3af
3 changed files with 22 additions and 11 deletions

View File

@ -13,9 +13,6 @@ const(
app_description = "Run and build your applications on file changes." app_description = "Run and build your applications on file changes."
app_author = "Alessio Pracchia" app_author = "Alessio Pracchia"
app_file = "realize.config.yaml" app_file = "realize.config.yaml"
watcher_ext = ".go"
watcher_path = "/"
watcher_ignore = "vendor"
) )
var wg sync.WaitGroup var wg sync.WaitGroup
@ -25,6 +22,10 @@ var red = color.New(color.FgRed).SprintFunc()
var blue = color.New(color.FgBlue, color.Bold).SprintFunc() var blue = color.New(color.FgBlue, color.Bold).SprintFunc()
var bluel = color.New(color.FgBlue).SprintFunc() var bluel = color.New(color.FgBlue).SprintFunc()
var watcher_ignores = []string {"vendor","bin"}
var watcher_exts = []string {".go"}
var watcher_paths = []string {"/"}
type App struct{ type App struct{
Name,Version,Description,Author,Email string Name,Version,Description,Author,Email string
} }

View File

@ -29,9 +29,9 @@ func New(params *cli.Context) *Config{
Build: params.Bool("build"), Build: params.Bool("build"),
Bin: params.Bool("bin"), Bin: params.Bool("bin"),
Watcher: Watcher{ Watcher: Watcher{
Paths: []string{watcher_path}, Paths: watcher_paths,
Ignore: []string{watcher_ignore}, Ignore: watcher_ignores,
Exts: []string{watcher_ext}, Exts: watcher_exts,
}, },
}, },
}, },
@ -107,9 +107,9 @@ func (h *Config) Add(params *cli.Context) error{
Run: params.Bool("run"), Run: params.Bool("run"),
Build: params.Bool("build"), Build: params.Bool("build"),
Watcher: Watcher{ Watcher: Watcher{
Paths: []string{watcher_path}, Paths: watcher_paths,
Exts: []string{watcher_ext}, Exts: watcher_exts,
Ignore: []string{watcher_ignore}, Ignore: watcher_ignores,
}, },
} }
if Duplicates(new, h.Projects) { if Duplicates(new, h.Projects) {

View File

@ -5,6 +5,7 @@ import (
"os/exec" "os/exec"
"os" "os"
"bytes" "bytes"
"fmt"
) )
type Project struct { type Project struct {
@ -25,10 +26,19 @@ func GoRun () error{
func (p *Project) GoBuild() error{ func (p *Project) GoBuild() error{
var out bytes.Buffer var out bytes.Buffer
base, _ := os.Getwd() base, _ := os.Getwd()
build := exec.Command("go", "build", base + p.Path + p.Main) path := base + p.Path
//build.Dir = base + p.Path
// create bin dir
if _, err := os.Stat(path + "bin"); err != nil {
if err = os.Mkdir(path + "bin", 0777); err != nil{
fmt.Println(err)
}
}
build := exec.Command("go", "build", path + p.Main)
build.Dir = path + "bin"
build.Stdout = &out build.Stdout = &out
if err := build.Run(); err != nil { if err := build.Run(); err != nil {
fmt.Println(err)
return err return err
} }
return nil return nil