commit
ba1c78c62c
0
Dockerfile
Normal file
0
Dockerfile
Normal file
0
docker-compose.yml
Normal file
0
docker-compose.yml
Normal file
@ -284,9 +284,10 @@ L:
|
|||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
case event := <-p.watcher.Events():
|
case event := <-p.watcher.Events():
|
||||||
|
if p.parent.Settings.Debug {
|
||||||
|
log.Println("Event:", event, "File:", event.Name, "LastFile:", p.lastFile, "Time:", time.Now(), "LastTime:", p.lastTime)
|
||||||
|
}
|
||||||
if time.Now().Truncate(time.Second).After(p.lastTime) || event.Name != p.lastFile {
|
if time.Now().Truncate(time.Second).After(p.lastTime) || event.Name != p.lastFile {
|
||||||
// event time
|
|
||||||
eventTime := time.Now()
|
|
||||||
// switch event type
|
// switch event type
|
||||||
switch event.Op {
|
switch event.Op {
|
||||||
case fsnotify.Chmod:
|
case fsnotify.Chmod:
|
||||||
@ -308,7 +309,7 @@ L:
|
|||||||
if fi.IsDir() {
|
if fi.IsDir() {
|
||||||
filepath.Walk(event.Name, p.walk)
|
filepath.Walk(event.Name, p.walk)
|
||||||
} else {
|
} else {
|
||||||
if event.Op != fsnotify.Write || (eventTime.Truncate(time.Millisecond).After(fi.ModTime().Truncate(time.Millisecond)) || event.Name != p.lastFile) {
|
if event.Op != fsnotify.Write || event.Name != p.lastFile {
|
||||||
// stop and restart
|
// stop and restart
|
||||||
close(p.stop)
|
close(p.stop)
|
||||||
p.stop = make(chan bool)
|
p.stop = make(chan bool)
|
||||||
@ -363,7 +364,7 @@ func (p *Project) Validate(path string, fiche bool) bool {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
if fi.IsDir() || (!fi.IsDir() && fi.Size() > 0) {
|
if fi.Size() > 0 {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
|
@ -29,9 +29,10 @@ const (
|
|||||||
// Settings defines a group of general settings and options
|
// Settings defines a group of general settings and options
|
||||||
type Settings struct {
|
type Settings struct {
|
||||||
Files `yaml:"files,omitempty" json:"files,omitempty"`
|
Files `yaml:"files,omitempty" json:"files,omitempty"`
|
||||||
Legacy Legacy `yaml:"legacy" json:"legacy"`
|
|
||||||
FileLimit int32 `yaml:"flimit,omitempty" json:"flimit,omitempty"`
|
|
||||||
Recovery bool `yaml:"recovery,omitempty" json:"recovery,omitempty"`
|
Recovery bool `yaml:"recovery,omitempty" json:"recovery,omitempty"`
|
||||||
|
Debug bool `yaml:"debug,omitempty" json:"debug,omitempty"`
|
||||||
|
FileLimit int32 `yaml:"flimit,omitempty" json:"flimit,omitempty"`
|
||||||
|
Legacy Legacy `yaml:"legacy" json:"legacy"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Legacy is used to force polling and set a custom interval
|
// Legacy is used to force polling and set a custom interval
|
||||||
|
@ -3,6 +3,7 @@ package realize
|
|||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"errors"
|
"errors"
|
||||||
|
"io/ioutil"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
@ -95,6 +96,18 @@ func (t *Tool) Exec(path string, stop <-chan bool) (response Response) {
|
|||||||
if filepath.Ext(path) != "" {
|
if filepath.Ext(path) != "" {
|
||||||
path = filepath.Dir(path)
|
path = filepath.Dir(path)
|
||||||
}
|
}
|
||||||
|
// check if there is at least one go file
|
||||||
|
matched := false
|
||||||
|
files, _ := ioutil.ReadDir(path)
|
||||||
|
for _, f := range files {
|
||||||
|
matched, _ = filepath.Match("*.go", f.Name())
|
||||||
|
if matched {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if !matched {
|
||||||
|
return
|
||||||
|
}
|
||||||
} else if !strings.HasSuffix(path, ".go") {
|
} else if !strings.HasSuffix(path, ".go") {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user