Merge pull request #1386 from cli/terminal-check-state

remove package level terminal check state
This commit is contained in:
Nate Smith 2020-07-20 11:07:50 -05:00 committed by GitHub
commit eb1b9122d8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 19 deletions

View file

@ -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`,
},

View file

@ -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)
}

View file

@ -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.