Skip to content

Commit

Permalink
🎨 pull all lipgloss assignments for CI round 7
Browse files Browse the repository at this point in the history
  • Loading branch information
acidjazz committed May 20, 2024
1 parent 8b7753a commit 5edec4b
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion taskin.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ import (
"github.com/charmbracelet/bubbles/spinner"
tea "github.com/charmbracelet/bubbletea"
"github.com/charmbracelet/lipgloss"
"io"
"os"
"regexp"
)

var program *tea.Program
Expand Down Expand Up @@ -49,9 +51,26 @@ func (task *Task) Progress(current, total int) {
}
}

type ansiEscapeCodeFilter struct {
writer io.Writer
}

func (f *ansiEscapeCodeFilter) Write(p []byte) (n int, err error) {
// Regular expression to match ANSI escape codes
re := regexp.MustCompile(`\x1b[^m]*m`)
// Remove the escape codes from the input
p = re.ReplaceAll(p, []byte{})
// Write the filtered input to the original writer
return f.writer.Write(p)
}

func (r *Runners) Run() error {
m := &Model{Runners: *r, Shutdown: false, ShutdownError: nil}
program = tea.NewProgram(m, tea.WithInput(nil))
if IsCI() {
program = tea.NewProgram(m, tea.WithInput(nil), tea.WithOutput(&ansiEscapeCodeFilter{writer: os.Stdout}))
} else {
program = tea.NewProgram(m, tea.WithInput(nil))
}
_, err := program.Run()
if err != nil {
program.Send(TerminateWithError{Error: err})
Expand Down

0 comments on commit 5edec4b

Please sign in to comment.