From 92cb369e005ad83850bc0360e44499aceeedea4e Mon Sep 17 00:00:00 2001 From: Artem Dvoretskii Date: Wed, 15 May 2024 23:53:46 +0300 Subject: [PATCH] try to fix missing tty error --- internal/tool/tool.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/internal/tool/tool.go b/internal/tool/tool.go index 918fdf3..480afb3 100644 --- a/internal/tool/tool.go +++ b/internal/tool/tool.go @@ -15,6 +15,7 @@ import ( tea "github.com/charmbracelet/bubbletea" "github.com/enescakir/emoji" "github.com/go-resty/resty/v2" + "github.com/mattn/go-isatty" "go.uber.org/zap" ) @@ -150,7 +151,13 @@ func (t *Tool) RunWithProgram(ctx context.Context, wg *sync.WaitGroup, errc chan func (t *Tool) run(ctx context.Context, wg *sync.WaitGroup) error { defer wg.Done() t.initialize() - t.prog = tea.NewProgram(t, tea.WithContext(ctx)) + var teaOpts = []tea.ProgramOption{tea.WithContext(ctx)} + if !isatty.IsTerminal(os.Stdout.Fd()) { + // workaround for missing tty when running in CI + // https://github.com/charmbracelet/bubbletea/issues/761 + teaOpts = append(teaOpts, tea.WithInput(nil)) + } + t.prog = tea.NewProgram(t, teaOpts...) wg.Add(1) go t.listenForEvents(ctx, wg) if _, err := t.prog.Run(); err != nil {