Skip to content

Commit

Permalink
watch all directories in the repositority with watch command
Browse files Browse the repository at this point in the history
part of #106
  • Loading branch information
Ivan Vlasic committed Mar 9, 2022
1 parent dc7dbfb commit bca936e
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
1 change: 1 addition & 0 deletions cli/controller/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const (
PublicDir = "public"
BuildDir = "build"
BinaryName = "bootstrap"
MainFile = "main.go"
DeployHTTPMethod = "deploy"
HashCharacters = 8
)
Expand Down
2 changes: 1 addition & 1 deletion cli/controller/deploy_functions.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func (d *Deploy) createMains() error {
}
for _, api := range apis {
dir := d.apiDir(api)
mainDest := filepath.Join(d.apiMainDir(api), "main.go")
mainDest := filepath.Join(d.apiMainDir(api), MainFile)
if err := generateMain(api, dir, mainDest); err != nil {
return log.Wrap(err)
}
Expand Down
9 changes: 7 additions & 2 deletions cli/controller/watch.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func Watch(a WatchArgs) error {
}
}

return w.run(fs.ProjectRoot() + "/api")
return w.run(fs.ProjectRoot())
}

type watch struct {
Expand Down Expand Up @@ -119,7 +119,12 @@ func (w *watch) run(path string) error {
go func() {
for {
select {
case <-wr.Event:
case e := <-wr.Event:
// due to contraints of the current watcher library finding a way to ignore automatically generated
// main.go files with other filters proved to be a challenge, adding this workaround for now.
if e.Name() == MainFile {
continue
}
w.onChange()
ui.Info("")
ui.Info("Watching changes in %s", path)
Expand Down

0 comments on commit bca936e

Please sign in to comment.