bugs fixed
This commit is contained in:
parent
1e2534a048
commit
f5cd6ebb02
|
@ -677,7 +677,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, Startup: 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})
|
||||||
d.Reload()
|
d.Reload()
|
||||||
return nil
|
return nil
|
||||||
},
|
},
|
||||||
|
@ -719,7 +719,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, Startup: 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})
|
||||||
d.Reload()
|
d.Reload()
|
||||||
return nil
|
return nil
|
||||||
},
|
},
|
||||||
|
|
|
@ -47,5 +47,5 @@ func TestSettings_Record(t *testing.T) {
|
||||||
if err := s.Record(a); err != nil {
|
if err := s.Record(a); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
s.Remove(filepath.Join(Directory, s.Resources.Config))
|
s.Remove(filepath.Join(directory, s.Resources.Config))
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,7 +27,7 @@ func (p *Project) goRun(channel chan bool, runner chan bool, wr *sync.WaitGroup)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
msg := fmt.Sprintln(p.pname(p.Name, 3), ":", style.Blue.Regular(err.Error()))
|
msg := fmt.Sprintln(p.pname(p.Name, 3), ":", style.Blue.Regular(err.Error()))
|
||||||
out := BufferOut{Time: time.Now(), Text: err.Error(), Type: "Go Run"}
|
out := BufferOut{Time: time.Now(), Text: err.Error(), Type: "Go Run"}
|
||||||
p.print("error", out, msg, "")
|
p.stamp("error", out, msg, "")
|
||||||
} else {
|
} else {
|
||||||
isErrorText = func(t string) bool {
|
isErrorText = func(t string) bool {
|
||||||
return errRegexp.MatchString(t)
|
return errRegexp.MatchString(t)
|
||||||
|
@ -63,7 +63,7 @@ func (p *Project) goRun(channel chan bool, runner chan bool, wr *sync.WaitGroup)
|
||||||
}
|
}
|
||||||
msg := fmt.Sprintln(p.pname(p.Name, 2), ":", style.Red.Regular("Ended"))
|
msg := fmt.Sprintln(p.pname(p.Name, 2), ":", style.Red.Regular("Ended"))
|
||||||
out := BufferOut{Time: time.Now(), Text: "Ended", Type: "Go Run"}
|
out := BufferOut{Time: time.Now(), Text: "Ended", Type: "Go Run"}
|
||||||
p.print("log", out, msg, "")
|
p.stamp("log", out, msg, "")
|
||||||
wr.Done()
|
wr.Done()
|
||||||
}()
|
}()
|
||||||
|
|
||||||
|
@ -87,10 +87,10 @@ func (p *Project) goRun(channel chan bool, runner chan bool, wr *sync.WaitGroup)
|
||||||
msg := fmt.Sprintln(p.pname(p.Name, 3), ":", style.Blue.Regular(text))
|
msg := fmt.Sprintln(p.pname(p.Name, 3), ":", style.Blue.Regular(text))
|
||||||
if isError && !isErrorText(text) {
|
if isError && !isErrorText(text) {
|
||||||
out := BufferOut{Time: time.Now(), Text: text, Type: "Go Run"}
|
out := BufferOut{Time: time.Now(), Text: text, Type: "Go Run"}
|
||||||
p.print("error", out, msg, "")
|
p.stamp("error", out, msg, "")
|
||||||
} else {
|
} else {
|
||||||
out := BufferOut{Time: time.Now(), Text: text, Type: "Go Run"}
|
out := BufferOut{Time: time.Now(), Text: text, Type: "Go Run"}
|
||||||
p.print("out", out, msg, "")
|
p.stamp("out", out, msg, "")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
close(stop)
|
close(stop)
|
||||||
|
|
|
@ -90,8 +90,7 @@ 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,omitempty" json:"path,omitempty"`
|
Path string `yaml:"path,omitempty" json:"path,omitempty"`
|
||||||
Changed bool `yaml:"changed,omitempty" json:"changed,omitempty"`
|
Global bool `yaml:"global,omitempty" json:"changed,global"`
|
||||||
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
|
||||||
|
|
|
@ -72,7 +72,7 @@ func (p *Project) watchByPolling() {
|
||||||
// repeat the initial cycle
|
// repeat the initial cycle
|
||||||
msg = fmt.Sprintln(p.pname(p.Name, 4), ":", style.Magenta.Bold(strings.ToUpper(ext[1:])+" changed"), style.Magenta.Bold(file))
|
msg = fmt.Sprintln(p.pname(p.Name, 4), ":", style.Magenta.Bold(strings.ToUpper(ext[1:])+" changed"), style.Magenta.Bold(file))
|
||||||
out = BufferOut{Time: time.Now(), Text: strings.ToUpper(ext[1:]) + " changed " + file}
|
out = BufferOut{Time: time.Now(), Text: strings.ToUpper(ext[1:]) + " changed " + file}
|
||||||
p.print("log", out, msg, "")
|
p.stamp("log", out, msg, "")
|
||||||
go p.routines(&wr, channel, watcher, file)
|
go p.routines(&wr, channel, watcher, file)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
@ -84,16 +84,15 @@ func (p *Project) watchByPolling() {
|
||||||
if err := filepath.Walk(base, walk); err != nil {
|
if err := filepath.Walk(base, walk); err != nil {
|
||||||
msg = fmt.Sprintln(p.pname(p.Name, 2), ":", style.Red.Regular(err.Error()))
|
msg = fmt.Sprintln(p.pname(p.Name, 2), ":", style.Red.Regular(err.Error()))
|
||||||
out = BufferOut{Time: time.Now(), Text: err.Error()}
|
out = BufferOut{Time: time.Now(), Text: err.Error()}
|
||||||
p.print("error", out, msg, "")
|
p.stamp("error", out, msg, "")
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
msg = fmt.Sprintln(p.pname(p.Name, 2), ":", base, "path doesn't exist")
|
msg = fmt.Sprintln(p.pname(p.Name, 2), ":", base, "path doesn't exist")
|
||||||
out = BufferOut{Time: time.Now(), Text: base + " path doesn't exist"}
|
out = BufferOut{Time: time.Now(), Text: base + " path doesn't exist"}
|
||||||
p.print("error", out, msg, "")
|
p.stamp("error", out, msg, "")
|
||||||
}
|
}
|
||||||
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))):
|
||||||
}
|
}
|
||||||
|
@ -138,7 +137,7 @@ func (p *Project) watchByNotify() {
|
||||||
// repeat the initial cycle
|
// repeat the initial cycle
|
||||||
msg = fmt.Sprintln(p.pname(p.Name, 4), ":", style.Magenta.Bold(strings.ToUpper(ext[1:])+" changed"), style.Magenta.Bold(file))
|
msg = fmt.Sprintln(p.pname(p.Name, 4), ":", style.Magenta.Bold(strings.ToUpper(ext[1:])+" changed"), style.Magenta.Bold(file))
|
||||||
out = BufferOut{Time: time.Now(), Text: strings.ToUpper(ext[1:]) + " changed " + file}
|
out = BufferOut{Time: time.Now(), Text: strings.ToUpper(ext[1:]) + " changed " + file}
|
||||||
p.print("log", out, msg, "")
|
p.stamp("log", out, msg, "")
|
||||||
go p.routines(&wr, channel, watcher, file)
|
go p.routines(&wr, channel, watcher, file)
|
||||||
p.LastChangedOn = time.Now().Truncate(time.Second)
|
p.LastChangedOn = time.Now().Truncate(time.Second)
|
||||||
}
|
}
|
||||||
|
@ -147,9 +146,8 @@ func (p *Project) watchByNotify() {
|
||||||
case err := <-watcher.Errors:
|
case err := <-watcher.Errors:
|
||||||
msg = fmt.Sprintln(p.pname(p.Name, 2), ":", style.Red.Regular(err.Error()))
|
msg = fmt.Sprintln(p.pname(p.Name, 2), ":", style.Red.Regular(err.Error()))
|
||||||
out = BufferOut{Time: time.Now(), Text: err.Error()}
|
out = BufferOut{Time: time.Now(), Text: err.Error()}
|
||||||
p.print("error", out, msg, "")
|
p.stamp("error", out, msg, "")
|
||||||
case <-exit:
|
case <-exit:
|
||||||
p.cmd("after", false)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -201,7 +199,7 @@ func (p *Project) watch(watcher watcher) error {
|
||||||
}
|
}
|
||||||
msg = fmt.Sprintln(p.pname(p.Name, 1), ":", style.Blue.Bold("Watching"), style.Magenta.Bold(files), "file/s", style.Magenta.Bold(folders), "folder/s")
|
msg = fmt.Sprintln(p.pname(p.Name, 1), ":", style.Blue.Bold("Watching"), style.Magenta.Bold(files), "file/s", style.Magenta.Bold(folders), "folder/s")
|
||||||
out = BufferOut{Time: time.Now(), Text: "Watching " + strconv.FormatInt(files, 10) + " files/s " + strconv.FormatInt(folders, 10) + " folder/s"}
|
out = BufferOut{Time: time.Now(), Text: "Watching " + strconv.FormatInt(files, 10) + " files/s " + strconv.FormatInt(folders, 10) + " folder/s"}
|
||||||
p.print("log", out, msg, "")
|
p.stamp("log", out, msg, "")
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -214,11 +212,11 @@ func (p *Project) install() error {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
msg = fmt.Sprintln(p.pname(p.Name, 2), ":", style.Red.Bold("Go Install"), style.Red.Regular(err.Error()))
|
msg = fmt.Sprintln(p.pname(p.Name, 2), ":", style.Red.Bold("Go Install"), style.Red.Regular(err.Error()))
|
||||||
out = BufferOut{Time: time.Now(), Text: err.Error(), Type: "Go Install", Stream: stream}
|
out = BufferOut{Time: time.Now(), Text: err.Error(), Type: "Go Install", Stream: stream}
|
||||||
p.print("error", out, msg, stream)
|
p.stamp("error", out, msg, stream)
|
||||||
} else {
|
} else {
|
||||||
msg = fmt.Sprintln(p.pname(p.Name, 5), ":", style.Green.Regular("Installed")+" after", style.Magenta.Regular(big.NewFloat(float64(time.Since(start).Seconds())).Text('f', 3), " s"))
|
msg = fmt.Sprintln(p.pname(p.Name, 5), ":", style.Green.Regular("Installed")+" after", style.Magenta.Regular(big.NewFloat(float64(time.Since(start).Seconds())).Text('f', 3), " s"))
|
||||||
out = BufferOut{Time: time.Now(), Text: "Installed after " + big.NewFloat(float64(time.Since(start).Seconds())).Text('f', 3) + " s"}
|
out = BufferOut{Time: time.Now(), Text: "Installed after " + big.NewFloat(float64(time.Since(start).Seconds())).Text('f', 3) + " s"}
|
||||||
p.print("log", out, msg, stream)
|
p.stamp("log", out, msg, stream)
|
||||||
}
|
}
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -237,7 +235,7 @@ func (p *Project) run(channel chan bool, wr *sync.WaitGroup) {
|
||||||
case <-runner:
|
case <-runner:
|
||||||
msg = fmt.Sprintln(p.pname(p.Name, 5), ":", style.Green.Regular("Started")+" after", style.Magenta.Regular(big.NewFloat(float64(time.Since(start).Seconds())).Text('f', 3), " s"))
|
msg = fmt.Sprintln(p.pname(p.Name, 5), ":", style.Green.Regular("Started")+" after", style.Magenta.Regular(big.NewFloat(float64(time.Since(start).Seconds())).Text('f', 3), " s"))
|
||||||
out = BufferOut{Time: time.Now(), Text: "Started after " + big.NewFloat(float64(time.Since(start).Seconds())).Text('f', 3) + " s"}
|
out = BufferOut{Time: time.Now(), Text: "Started after " + big.NewFloat(float64(time.Since(start).Seconds())).Text('f', 3) + " s"}
|
||||||
p.print("log", out, msg, "")
|
p.stamp("log", out, msg, "")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -253,11 +251,11 @@ func (p *Project) build() error {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
msg = fmt.Sprintln(p.pname(p.Name, 2), ":", style.Red.Bold("Go Build"), style.Red.Regular(err.Error()))
|
msg = fmt.Sprintln(p.pname(p.Name, 2), ":", style.Red.Bold("Go Build"), style.Red.Regular(err.Error()))
|
||||||
out = BufferOut{Time: time.Now(), Text: err.Error(), Type: "Go Build", Stream: stream}
|
out = BufferOut{Time: time.Now(), Text: err.Error(), Type: "Go Build", Stream: stream}
|
||||||
p.print("error", out, msg, stream)
|
p.stamp("error", out, msg, stream)
|
||||||
} else {
|
} else {
|
||||||
msg = fmt.Sprintln(p.pname(p.Name, 5), ":", style.Green.Regular("Built")+" after", style.Magenta.Regular(big.NewFloat(float64(time.Since(start).Seconds())).Text('f', 3), " s"))
|
msg = fmt.Sprintln(p.pname(p.Name, 5), ":", style.Green.Regular("Built")+" after", style.Magenta.Regular(big.NewFloat(float64(time.Since(start).Seconds())).Text('f', 3), " s"))
|
||||||
out = BufferOut{Time: time.Now(), Text: "Built after " + big.NewFloat(float64(time.Since(start).Seconds())).Text('f', 3) + " s"}
|
out = BufferOut{Time: time.Now(), Text: "Built after " + big.NewFloat(float64(time.Since(start).Seconds())).Text('f', 3) + " s"}
|
||||||
p.print("log", out, msg, stream)
|
p.stamp("log", out, msg, stream)
|
||||||
}
|
}
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -275,7 +273,7 @@ func (p *Project) tool(path string, tool tool) error {
|
||||||
if stream, err := p.goTools(path, tool.cmd, tool.options...); err != nil {
|
if stream, err := p.goTools(path, tool.cmd, tool.options...); err != nil {
|
||||||
msg = fmt.Sprintln(p.pname(p.Name, 2), ":", style.Red.Bold(tool.name), style.Red.Regular("there are some errors in"), ":", style.Magenta.Bold(path))
|
msg = fmt.Sprintln(p.pname(p.Name, 2), ":", style.Red.Bold(tool.name), style.Red.Regular("there are some errors in"), ":", style.Magenta.Bold(path))
|
||||||
out = BufferOut{Time: time.Now(), Text: "there are some errors in", Path: path, Type: tool.name, Stream: stream}
|
out = BufferOut{Time: time.Now(), Text: "there are some errors in", Path: path, Type: tool.name, Stream: stream}
|
||||||
p.print("error", out, msg, stream)
|
p.stamp("error", out, msg, stream)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -284,29 +282,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, global bool) {
|
||||||
for _, cmd := range p.Watcher.Scripts {
|
for _, cmd := range p.Watcher.Scripts {
|
||||||
if strings.ToLower(cmd.Type) == flag {
|
if strings.ToLower(cmd.Type) == flag {
|
||||||
if changed && cmd.Changed || !changed && cmd.Startup {
|
err, logs := p.command(cmd)
|
||||||
errors, logs := p.command(cmd)
|
|
||||||
msg = fmt.Sprintln(p.pname(p.Name, 5), ":", style.Green.Bold("Command"), style.Green.Bold("\"")+cmd.Command+style.Green.Bold("\""))
|
msg = fmt.Sprintln(p.pname(p.Name, 5), ":", style.Green.Bold("Command"), style.Green.Bold("\"")+cmd.Command+style.Green.Bold("\""))
|
||||||
out = BufferOut{Time: time.Now(), Text: cmd.Command, Type: flag}
|
out = BufferOut{Time: time.Now(), Text: cmd.Command, Type: flag}
|
||||||
if logs != "" {
|
if logs != "" {
|
||||||
p.print("log", out, msg, "")
|
p.stamp("log", out, msg, "")
|
||||||
}
|
}
|
||||||
if errors != "" {
|
if err != "" {
|
||||||
p.print("error", out, msg, "")
|
p.stamp("error", out, msg, "")
|
||||||
}
|
}
|
||||||
if logs != "" {
|
if logs != "" {
|
||||||
msg = fmt.Sprintln(logs)
|
msg = fmt.Sprintln(logs)
|
||||||
out = BufferOut{Time: time.Now(), Text: logs, Type: flag}
|
out = BufferOut{Time: time.Now(), Text: logs, Type: flag}
|
||||||
p.print("log", out, "", msg)
|
p.stamp("log", out, "", msg)
|
||||||
}
|
|
||||||
if errors != "" {
|
|
||||||
msg = fmt.Sprintln(style.Red.Regular(errors))
|
|
||||||
out = BufferOut{Time: time.Now(), Text: errors, Type: flag}
|
|
||||||
p.print("error", out, "", msg)
|
|
||||||
}
|
}
|
||||||
|
if err != "" {
|
||||||
|
msg = fmt.Sprintln(style.Red.Regular(err))
|
||||||
|
out = BufferOut{Time: time.Now(), Text: err, Type: flag}
|
||||||
|
p.stamp("error", out, "", msg)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -325,14 +321,13 @@ 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", false)
|
||||||
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.Fatal(p.watch(watcher))
|
p.Fatal(p.watch(watcher))
|
||||||
}
|
}
|
||||||
install := p.install()
|
install := p.install()
|
||||||
|
@ -343,7 +338,7 @@ func (p *Project) routines(wr *sync.WaitGroup, channel chan bool, watcher watche
|
||||||
}
|
}
|
||||||
wr.Wait()
|
wr.Wait()
|
||||||
if len(file) > 0 {
|
if len(file) > 0 {
|
||||||
p.cmd("after", true)
|
p.cmd("after", false)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -371,7 +366,7 @@ func (p *Project) pname(name string, color int) string {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Print on files, cli, ws
|
// Print on files, cli, ws
|
||||||
func (p *Project) print(t string, o BufferOut, msg string, stream string) {
|
func (p *Project) stamp(t string, o BufferOut, msg string, stream string) {
|
||||||
switch t {
|
switch t {
|
||||||
case "out":
|
case "out":
|
||||||
p.Buffer.StdOut = append(p.Buffer.StdOut, o)
|
p.Buffer.StdOut = append(p.Buffer.StdOut, o)
|
||||||
|
|
Loading…
Reference in New Issue