From 96d5db57661725f143b20a35949536d7a2430007 Mon Sep 17 00:00:00 2001 From: kevin olson Date: Mon, 6 May 2024 01:24:50 -0500 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20modified=20the=20view=20to=20only?= =?UTF-8?q?=20paint=20when=20alldone=20for=20CI?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- mvc.go | 21 +++++++++++++++++++++ taskin.go | 1 - 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/mvc.go b/mvc.go index a0a51ec..07a098a 100644 --- a/mvc.go +++ b/mvc.go @@ -68,8 +68,29 @@ func (r *Runners) Update(msg tea.Msg) (tea.Model, tea.Cmd) { return r, nil } +func (r *Runners) checkTasksState() (allDone, anyFailed bool) { + allDone = true + for _, runner := range *r { + if runner.State != Completed && runner.State != Failed { + allDone = false + } + if runner.State == Failed { + anyFailed = true + } + } + return +} + func (r *Runners) View() string { var view string + + // check if CI is set, if it is then don't return the view until all tasks are completed or one has failed + if os.Getenv("CI") != "" { + allDone, _ := r.checkTasksState() + if !allDone { + return "" + } + } for _, runner := range *r { status := "" switch runner.State { diff --git a/taskin.go b/taskin.go index cb1c860..b421bc8 100644 --- a/taskin.go +++ b/taskin.go @@ -65,7 +65,6 @@ func New(tasks Tasks, cfg Config) Runners { for _, runner := range runners[:i] { if runner.State == Failed { - program.Send(spinner.TickMsg{}) return } }