diff --git a/README.md b/README.md index 074357c..b105f21 100644 --- a/README.md +++ b/README.md @@ -66,8 +66,10 @@ format: fail: "\u001b[38;5;244m[{{.Time}}] \u001b[38;5;1m[{{.Title}}] \u001b[38;5;238m{{.Message}}\u001b[0m\n" command_ok: "\u001b[38;5;240m[{{.Time}}] [{{.Title}}] \u001b[0m{{.Message}}\n" command_err: "\u001b[38;5;240m[{{.Time}}] [{{.Title}}] \u001b[38;5;1m{{.Message}}\u001b[0m\n" -trig: [start, buildNRun] # will run on start -trig_async: true +trig: [start, buildNRun] # will run start and after buildNRun +trig_async: # will run test and async concurrently + - test + - async env: - name: PORT value: 2000 @@ -84,7 +86,6 @@ rules: value: development - name: %{BASE_FILE}% # replace from environment type: file - trig_async: false trig: - done build - run @@ -100,6 +101,8 @@ rules: type: file match: _test\.go$ command: go test -cover {PKG} + - name: async + command: echo async ``` Example base.env diff --git a/pkg/wtc/config.go b/pkg/wtc/config.go index bee5935..8c3858f 100644 --- a/pkg/wtc/config.go +++ b/pkg/wtc/config.go @@ -7,7 +7,7 @@ type Config struct { Debounce int `yaml:"debounce"` Rules []*Rule `yaml:"rules"` Trig []string `yaml:"trig"` - TrigAsync bool `yaml:"trig_async"` + TrigAsync []string `yaml:"trig_async"` ExitOnTrig bool `yaml:"-"` Env []*Env `yaml:"env"` Format struct { @@ -27,7 +27,7 @@ type Rule struct { Debounce *int `yaml:"debounce"` Command string `yaml:"command"` Trig []string `yaml:"trig"` - TrigAsync bool `yaml:"trig_async"` + TrigAsync []string `yaml:"trig_async"` Env []*Env `yaml:"env"` } diff --git a/pkg/wtc/wtc.go b/pkg/wtc/wtc.go index 86bda11..35dafe1 100644 --- a/pkg/wtc/wtc.go +++ b/pkg/wtc/wtc.go @@ -171,10 +171,13 @@ func Start(cfg *Config) { }() go func() { - findAndTrig(config.TrigAsync, config.Trig, "./", "./") if config.ExitOnTrig { + findAndTrig(false, config.Trig, "./", "./") os.Exit(0) } + + go findAndTrig(true, config.TrigAsync, "./", "./") + findAndTrig(false, config.Trig, "./", "./") }() c := make(chan notify.EventInfo) @@ -424,7 +427,8 @@ func trig(rule *Rule, pkg, path string) error { return err } - findAndTrig(rule.TrigAsync, rule.Trig, pkg, path) + go findAndTrig(true, rule.TrigAsync, pkg, path) + findAndTrig(false, rule.Trig, pkg, path) return nil }