From 982999e3afeb8df10fe64c58a152b96eb56d5938 Mon Sep 17 00:00:00 2001 From: alessio Date: Wed, 3 Aug 2016 16:46:36 +0200 Subject: [PATCH] build fix --- realize/app.go | 7 ++++--- realize/config.go | 12 ++++++------ realize/project.go | 14 ++++++++++++-- 3 files changed, 22 insertions(+), 11 deletions(-) diff --git a/realize/app.go b/realize/app.go index 22995cf..f32fb03 100644 --- a/realize/app.go +++ b/realize/app.go @@ -13,9 +13,6 @@ const( app_description = "Run and build your applications on file changes." app_author = "Alessio Pracchia" app_file = "realize.config.yaml" - watcher_ext = ".go" - watcher_path = "/" - watcher_ignore = "vendor" ) 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 bluel = color.New(color.FgBlue).SprintFunc() +var watcher_ignores = []string {"vendor","bin"} +var watcher_exts = []string {".go"} +var watcher_paths = []string {"/"} + type App struct{ Name,Version,Description,Author,Email string } diff --git a/realize/config.go b/realize/config.go index e62bc14..5f3a0cf 100644 --- a/realize/config.go +++ b/realize/config.go @@ -29,9 +29,9 @@ func New(params *cli.Context) *Config{ Build: params.Bool("build"), Bin: params.Bool("bin"), Watcher: Watcher{ - Paths: []string{watcher_path}, - Ignore: []string{watcher_ignore}, - Exts: []string{watcher_ext}, + Paths: watcher_paths, + Ignore: watcher_ignores, + Exts: watcher_exts, }, }, }, @@ -107,9 +107,9 @@ func (h *Config) Add(params *cli.Context) error{ Run: params.Bool("run"), Build: params.Bool("build"), Watcher: Watcher{ - Paths: []string{watcher_path}, - Exts: []string{watcher_ext}, - Ignore: []string{watcher_ignore}, + Paths: watcher_paths, + Exts: watcher_exts, + Ignore: watcher_ignores, }, } if Duplicates(new, h.Projects) { diff --git a/realize/project.go b/realize/project.go index 6dc0b50..a6ecda0 100644 --- a/realize/project.go +++ b/realize/project.go @@ -5,6 +5,7 @@ import ( "os/exec" "os" "bytes" + "fmt" ) type Project struct { @@ -25,10 +26,19 @@ func GoRun () error{ func (p *Project) GoBuild() error{ var out bytes.Buffer base, _ := os.Getwd() - build := exec.Command("go", "build", base + p.Path + p.Main) - //build.Dir = base + p.Path + path := 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 if err := build.Run(); err != nil { + fmt.Println(err) return err } return nil