增加 ignore*指令支持
This commit is contained in:
parent
3351429515
commit
1b4206a6b3
@ -18,8 +18,12 @@ import (
|
||||
const (
|
||||
Version = 1
|
||||
|
||||
InstExecWhenStart = "exec-when-start"
|
||||
InstShouldFinish = "should-finish"
|
||||
InstExecWhenStart = "exec-when-start"
|
||||
InstShouldFinish = "should-finish"
|
||||
InstIgnoreWarn = "ignore-warn"
|
||||
InstIgnoreInfo = "ignore-info"
|
||||
InstIgnoreStdout = "ignore-stdout"
|
||||
InstIgnoreExecError = "ignore-exec-error"
|
||||
)
|
||||
|
||||
var (
|
||||
|
@ -93,17 +93,26 @@ func (t *TaskMan) run(cf *changedFile) {
|
||||
//cmd.SysProcAttr = &syscall.SysProcAttr{CreationFlags: syscall.CREATE_UNICODE_ENVIRONMENT}
|
||||
t.cmd.Stdin = os.Stdin
|
||||
t.cmd.Stdout = os.Stdout
|
||||
if keyInInstruction(InstIgnoreStdout) {
|
||||
t.cmd.Stdout = nil
|
||||
}
|
||||
t.cmd.Stderr = os.Stderr
|
||||
t.cmd.Dir = projectFolder
|
||||
t.cmd.Env = os.Environ()
|
||||
err := t.cmd.Start()
|
||||
if err != nil {
|
||||
logError("run command", carr, "error. ", err)
|
||||
if keyInInstruction(InstIgnoreExecError) {
|
||||
continue
|
||||
}
|
||||
break
|
||||
}
|
||||
err = t.cmd.Wait()
|
||||
if err != nil {
|
||||
logWarn("command exec failed:", carr, err)
|
||||
if keyInInstruction(InstIgnoreExecError) {
|
||||
continue
|
||||
}
|
||||
break
|
||||
}
|
||||
if t.cmd.Process != nil {
|
||||
|
6
util.go
6
util.go
@ -82,11 +82,17 @@ func inStrArray(s string, arr []string) bool {
|
||||
}
|
||||
|
||||
func logInfo(v ...interface{}) {
|
||||
if keyInInstruction(InstIgnoreInfo) {
|
||||
return
|
||||
}
|
||||
v = append([]interface{}{"I:"}, v...)
|
||||
log.Println(v...)
|
||||
}
|
||||
|
||||
func logWarn(v ...interface{}) {
|
||||
if keyInInstruction(InstIgnoreWarn) {
|
||||
return
|
||||
}
|
||||
v = append([]interface{}{"W:"}, v...)
|
||||
log.Println(v...)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user