Merge remote-tracking branch 'origin/dev' into dev

This commit is contained in:
alessio 2017-04-26 16:09:42 +02:00
commit 350bdbb4a6
2 changed files with 23 additions and 10 deletions

View File

@ -8,6 +8,7 @@ import (
"os" "os"
"os/exec" "os/exec"
"path/filepath" "path/filepath"
"regexp"
"strings" "strings"
"sync" "sync"
"time" "time"
@ -19,6 +20,19 @@ func (p *Project) goRun(channel chan bool, runner chan bool, wr *sync.WaitGroup)
var build *exec.Cmd var build *exec.Cmd
var args []string var args []string
var path = "" var path = ""
isErrorText := func(string) bool {
return false
}
errRegexp, err := regexp.Compile(p.ErrorOutputPattern)
if err != nil {
msg := fmt.Sprintln(p.pname(p.Name, 3), ":", style.Blue.Regular(err.Error()))
out := BufferOut{Time: time.Now(), Text: err.Error(), Type: "Go Run"}
p.print("error", out, msg, "")
} else {
isErrorText = func(t string) bool {
return errRegexp.MatchString(t)
}
}
for _, arg := range p.Args { for _, arg := range p.Args {
arr := strings.Fields(arg) arr := strings.Fields(arg)
args = append(args, arr...) args = append(args, arr...)
@ -69,16 +83,14 @@ func (p *Project) goRun(channel chan bool, runner chan bool, wr *sync.WaitGroup)
stopOutput, stopError := make(chan bool, 1), make(chan bool, 1) stopOutput, stopError := make(chan bool, 1), make(chan bool, 1)
scanner := func(stop chan bool, output *bufio.Scanner, isError bool) { scanner := func(stop chan bool, output *bufio.Scanner, isError bool) {
for output.Scan() { for output.Scan() {
select { text := output.Text()
default: msg := fmt.Sprintln(p.pname(p.Name, 3), ":", style.Blue.Regular(text))
msg := fmt.Sprintln(p.pname(p.Name, 3), ":", style.Blue.Regular(output.Text())) if isError || isErrorText(text) {
if isError { out := BufferOut{Time: time.Now(), Text: text, Type: "Go Run"}
out := BufferOut{Time: time.Now(), Text: output.Text(), Type: "Go Run"} p.print("error", out, msg, "")
p.print("error", out, msg, "") } else {
} else { out := BufferOut{Time: time.Now(), Text: text}
out := BufferOut{Time: time.Now(), Text: output.Text()} p.print("out", out, msg, "")
p.print("out", out, msg, "")
}
} }
} }
close(stop) close(stop)

View File

@ -41,6 +41,7 @@ type Project struct {
Watcher Watcher `yaml:"watcher" json:"watcher"` Watcher Watcher `yaml:"watcher" json:"watcher"`
Streams Streams `yaml:"streams" json:"streams"` Streams Streams `yaml:"streams" json:"streams"`
Buffer Buffer `yaml:"-" json:"buffer"` Buffer Buffer `yaml:"-" json:"buffer"`
ErrorOutputPattern string `yaml:"errorOutputPattern" json:"errorOutputPattern"`
parent *Blueprint parent *Blueprint
path string path string
tools tools tools tools