added build and install in watcher
This commit is contained in:
parent
e98dd76f9b
commit
446d7c8071
|
@ -20,6 +20,26 @@ type Watcher struct{
|
||||||
Preview bool `yaml:"preview,omitempty"`
|
Preview bool `yaml:"preview,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (p *Project) install(){
|
||||||
|
if p.Bin {
|
||||||
|
if err := p.GoInstall(); err != nil{
|
||||||
|
Fail(err.Error())
|
||||||
|
}else{
|
||||||
|
Success(p.Name + ": Installed")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *Project) build(){
|
||||||
|
if p.Build {
|
||||||
|
if err := p.GoBuild(); err != nil{
|
||||||
|
Fail(err.Error())
|
||||||
|
}else{
|
||||||
|
Success(p.Name + ": Builded")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func (p *Project) Watching(){
|
func (p *Project) Watching(){
|
||||||
|
|
||||||
var watcher *fsnotify.Watcher
|
var watcher *fsnotify.Watcher
|
||||||
|
@ -43,8 +63,11 @@ func (p *Project) Watching(){
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// run, bin, build
|
// run go build
|
||||||
p.GoBuild()
|
go p.build()
|
||||||
|
|
||||||
|
// run go install
|
||||||
|
p.install()
|
||||||
|
|
||||||
p.reload = time.Now().Truncate(time.Second)
|
p.reload = time.Now().Truncate(time.Second)
|
||||||
|
|
||||||
|
@ -74,7 +97,13 @@ func (p *Project) Watching(){
|
||||||
if _, err := os.Stat(event.Name); err == nil {
|
if _, err := os.Stat(event.Name); err == nil {
|
||||||
i := strings.Index(event.Name, filepath.Ext(event.Name))
|
i := strings.Index(event.Name, filepath.Ext(event.Name))
|
||||||
log.Println(green(p.Name+":")+"\t", event.Name[:i])
|
log.Println(green(p.Name+":")+"\t", event.Name[:i])
|
||||||
// run, bin, build
|
|
||||||
|
// run go build
|
||||||
|
go p.build()
|
||||||
|
|
||||||
|
// run go install
|
||||||
|
p.install()
|
||||||
|
|
||||||
p.reload = time.Now().Truncate(time.Second)
|
p.reload = time.Now().Truncate(time.Second)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue