From b7765591b7a553727f170bbe9a8f5b2670b631a2 Mon Sep 17 00:00:00 2001 From: vilmibm Date: Fri, 17 Jul 2020 12:31:04 -0500 Subject: [PATCH] remove package level terminal check state --- command/issue_test.go | 16 ++++++++-------- utils/color.go | 5 ++--- utils/terminal.go | 8 -------- 3 files changed, 10 insertions(+), 19 deletions(-) diff --git a/command/issue_test.go b/command/issue_test.go index 24dc094c5..e9db1ca22 100644 --- a/command/issue_test.go +++ b/command/issue_test.go @@ -438,7 +438,7 @@ func TestIssueView_tty_Preview(t *testing.T) { fixture: "../test/fixtures/issueView_preview.json", expectedOutputs: []string{ `ix of coins`, - `Open • marseilles opened about 292 years ago • 9 comments`, + `Open.*marseilles opened about 292 years ago.*9 comments`, `bold story`, `View this issue on GitHub: https://github.com/OWNER/REPO/issues/123`, }, @@ -449,11 +449,11 @@ func TestIssueView_tty_Preview(t *testing.T) { fixture: "../test/fixtures/issueView_previewWithMetadata.json", expectedOutputs: []string{ `ix of coins`, - `Open • marseilles opened about 292 years ago • 9 comments`, - `Assignees: marseilles, monaco\n`, - `Labels: one, two, three, four, five\n`, - `Projects: Project 1 \(column A\), Project 2 \(column B\), Project 3 \(column C\), Project 4 \(Awaiting triage\)\n`, - `Milestone: uluru\n`, + `Open.*marseilles opened about 292 years ago.*9 comments`, + `Assignees:.*marseilles, monaco\n`, + `Labels:.*one, two, three, four, five\n`, + `Projects:.*Project 1 \(column A\), Project 2 \(column B\), Project 3 \(column C\), Project 4 \(Awaiting triage\)\n`, + `Milestone:.*uluru\n`, `bold story`, `View this issue on GitHub: https://github.com/OWNER/REPO/issues/123`, }, @@ -464,7 +464,7 @@ func TestIssueView_tty_Preview(t *testing.T) { fixture: "../test/fixtures/issueView_previewWithEmptyBody.json", expectedOutputs: []string{ `ix of coins`, - `Open • marseilles opened about 292 years ago • 9 comments`, + `Open.*marseilles opened about 292 years ago.*9 comments`, `View this issue on GitHub: https://github.com/OWNER/REPO/issues/123`, }, }, @@ -474,7 +474,7 @@ func TestIssueView_tty_Preview(t *testing.T) { fixture: "../test/fixtures/issueView_previewClosedState.json", expectedOutputs: []string{ `ix of coins`, - `Closed • marseilles opened about 292 years ago • 9 comments`, + `Closed.*marseilles opened about 292 years ago.*9 comments`, `bold story`, `View this issue on GitHub: https://github.com/OWNER/REPO/issues/123`, }, diff --git a/utils/color.go b/utils/color.go index 43a3277f9..123e0927c 100644 --- a/utils/color.go +++ b/utils/color.go @@ -9,8 +9,6 @@ import ( ) var ( - _isStdoutTerminal, checkedTerminal bool - // Outputs ANSI color if stdout is a tty Magenta = makeColorFunc("magenta") Cyan = makeColorFunc("cyan") @@ -45,5 +43,6 @@ func isColorEnabled() bool { return false } - return isStdoutTerminal() + // TODO ignores cmd.OutOrStdout + return IsTerminal(os.Stdout) } diff --git a/utils/terminal.go b/utils/terminal.go index 29d36a184..f79848e8e 100644 --- a/utils/terminal.go +++ b/utils/terminal.go @@ -8,14 +8,6 @@ import ( "golang.org/x/crypto/ssh/terminal" ) -func isStdoutTerminal() bool { - if !checkedTerminal { - _isStdoutTerminal = IsTerminal(os.Stdout) - checkedTerminal = true - } - return _isStdoutTerminal -} - // TODO I don't like this use of interface{} but we need to accept both io.Writer and io.Reader // interfaces.