#56 fixed
This commit is contained in:
parent
f4547b9e87
commit
fb8c09c798
@ -741,7 +741,7 @@ func main() {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return d.Err()
|
return d.Err()
|
||||||
}
|
}
|
||||||
r.Blueprint.Projects[len(r.Blueprint.Projects)-1].Watcher.Scripts = append(r.Blueprint.Projects[len(r.Blueprint.Projects)-1].Watcher.Scripts, watcher.Command{Type: "before", Command: val, Changed: true})
|
r.Blueprint.Projects[len(r.Blueprint.Projects)-1].Watcher.Scripts = append(r.Blueprint.Projects[len(r.Blueprint.Projects)-1].Watcher.Scripts, watcher.Command{Type: "before", Command: val, Changed: true, Startup: true})
|
||||||
d.Reload()
|
d.Reload()
|
||||||
return nil
|
return nil
|
||||||
},
|
},
|
||||||
@ -783,7 +783,7 @@ func main() {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return d.Err()
|
return d.Err()
|
||||||
}
|
}
|
||||||
r.Blueprint.Projects[len(r.Blueprint.Projects)-1].Watcher.Scripts = append(r.Blueprint.Projects[len(r.Blueprint.Projects)-1].Watcher.Scripts, watcher.Command{Type: "after", Command: val, Changed: true})
|
r.Blueprint.Projects[len(r.Blueprint.Projects)-1].Watcher.Scripts = append(r.Blueprint.Projects[len(r.Blueprint.Projects)-1].Watcher.Scripts, watcher.Command{Type: "after", Command: val, Changed: true, Startup: true})
|
||||||
d.Reload()
|
d.Reload()
|
||||||
return nil
|
return nil
|
||||||
},
|
},
|
||||||
|
@ -87,8 +87,9 @@ type Watcher struct {
|
|||||||
type Command struct {
|
type Command struct {
|
||||||
Type string `yaml:"type" json:"type"`
|
Type string `yaml:"type" json:"type"`
|
||||||
Command string `yaml:"command" json:"command"`
|
Command string `yaml:"command" json:"command"`
|
||||||
Path string `yaml:"path" json:"path"`
|
Path string `yaml:"path,omitempty" json:"path,omitempty"`
|
||||||
Changed bool `yaml:"refresh" json:"refresh"`
|
Changed bool `yaml:"changed,omitempty" json:"changed,omitempty"`
|
||||||
|
Startup bool `yaml:"startup,omitempty" json:"startup,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Streams is a collection of names and values for the logs functionality
|
// Streams is a collection of names and values for the logs functionality
|
||||||
|
@ -93,6 +93,7 @@ func (p *Project) watchByPolling() {
|
|||||||
}
|
}
|
||||||
select {
|
select {
|
||||||
case <-exit:
|
case <-exit:
|
||||||
|
p.cmd("after", false)
|
||||||
return
|
return
|
||||||
case <-time.After(p.parent.Legacy.Interval / time.Duration(len(p.Watcher.Paths))):
|
case <-time.After(p.parent.Legacy.Interval / time.Duration(len(p.Watcher.Paths))):
|
||||||
}
|
}
|
||||||
@ -148,6 +149,7 @@ func (p *Project) watchByNotify() {
|
|||||||
out = BufferOut{Time: time.Now(), Text: err.Error()}
|
out = BufferOut{Time: time.Now(), Text: err.Error()}
|
||||||
p.print("error", out, msg, "")
|
p.print("error", out, msg, "")
|
||||||
case <-exit:
|
case <-exit:
|
||||||
|
p.cmd("after", false)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -284,25 +286,27 @@ func (p *Project) tool(path string, tool tool) error {
|
|||||||
// Cmd calls an wrapper for execute the commands after/before
|
// Cmd calls an wrapper for execute the commands after/before
|
||||||
func (p *Project) cmd(flag string, changed bool) {
|
func (p *Project) cmd(flag string, changed bool) {
|
||||||
for _, cmd := range p.Watcher.Scripts {
|
for _, cmd := range p.Watcher.Scripts {
|
||||||
if strings.ToLower(cmd.Type) == flag && changed == cmd.Changed {
|
if strings.ToLower(cmd.Type) == flag{
|
||||||
errors, logs := p.command(cmd)
|
if changed && cmd.Changed || !changed && cmd.Startup {
|
||||||
msg = fmt.Sprintln(p.pname(p.Name, 5), ":", style.Green.Bold("Command"), style.Green.Bold("\"")+cmd.Command+style.Green.Bold("\""))
|
errors, logs := p.command(cmd)
|
||||||
out = BufferOut{Time: time.Now(), Text: cmd.Command, Type: flag}
|
msg = fmt.Sprintln(p.pname(p.Name, 5), ":", style.Green.Bold("Command"), style.Green.Bold("\"") + cmd.Command + style.Green.Bold("\""))
|
||||||
if logs != "" {
|
out = BufferOut{Time: time.Now(), Text: cmd.Command, Type: flag}
|
||||||
p.print("log", out, msg, "")
|
if logs != "" {
|
||||||
}
|
p.print("log", out, msg, "")
|
||||||
if errors != "" {
|
}
|
||||||
p.print("error", out, msg, "")
|
if errors != "" {
|
||||||
}
|
p.print("error", out, msg, "")
|
||||||
if logs != "" {
|
}
|
||||||
msg = fmt.Sprintln(logs)
|
if logs != "" {
|
||||||
out = BufferOut{Time: time.Now(), Text: logs, Type: flag}
|
msg = fmt.Sprintln(logs)
|
||||||
p.print("log", out, "", msg)
|
out = BufferOut{Time: time.Now(), Text: logs, Type: flag}
|
||||||
}
|
p.print("log", out, "", msg)
|
||||||
if errors != "" {
|
}
|
||||||
msg = fmt.Sprintln(style.Red.Regular(errors))
|
if errors != "" {
|
||||||
out = BufferOut{Time: time.Now(), Text: errors, Type: flag}
|
msg = fmt.Sprintln(style.Red.Regular(errors))
|
||||||
p.print("error", out, "", msg)
|
out = BufferOut{Time: time.Now(), Text: errors, Type: flag}
|
||||||
|
p.print("error", out, "", msg)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -320,14 +324,14 @@ func (p *Project) ignore(str string) bool {
|
|||||||
|
|
||||||
// Routines launches the toolchain run, build, install
|
// Routines launches the toolchain run, build, install
|
||||||
func (p *Project) routines(wr *sync.WaitGroup,channel chan bool, watcher watcher, file string) {
|
func (p *Project) routines(wr *sync.WaitGroup,channel chan bool, watcher watcher, file string) {
|
||||||
if len(file) > 0{
|
if len(file) > 0 {
|
||||||
p.cmd("before", true)
|
p.cmd("before", true)
|
||||||
path := filepath.Dir(file)
|
path := filepath.Dir(file)
|
||||||
p.tool(file, p.tools.Fmt)
|
p.tool(file, p.tools.Fmt)
|
||||||
p.tool(path, p.tools.Vet)
|
p.tool(path, p.tools.Vet)
|
||||||
p.tool(path, p.tools.Test)
|
p.tool(path, p.tools.Test)
|
||||||
p.tool(path, p.tools.Generate)
|
p.tool(path, p.tools.Generate)
|
||||||
}else{
|
} else {
|
||||||
p.cmd("before", false)
|
p.cmd("before", false)
|
||||||
p.Fatal(p.watch(watcher))
|
p.Fatal(p.watch(watcher))
|
||||||
}
|
}
|
||||||
@ -340,9 +344,8 @@ func (p *Project) routines(wr *sync.WaitGroup,channel chan bool, watcher watcher
|
|||||||
wr.Wait()
|
wr.Wait()
|
||||||
if len(file) > 0 {
|
if len(file) > 0 {
|
||||||
p.cmd("after", true)
|
p.cmd("after", true)
|
||||||
}else{
|
|
||||||
p.cmd("after", false)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Defines the colors scheme for the project name
|
// Defines the colors scheme for the project name
|
||||||
|
Loading…
Reference in New Issue
Block a user