Closed Fil closed 2 days ago
Generally we've been pushing these tty checks higher in the call stack, so that we can have different messages on non-TTYs. In the deploy effects we have a isTty
variable that we can use in tests to test both kinds of messages. I'd prefer if we keep that pattern instead of making Clack sometimes behave differently.
isTty
tests whether stdin is a tty, which will orient the questions one way or the other.
This by contrast is checking if stdout is a tty, so that we know not to output control characters; this is similar to what we do with color() in https://github.com/observablehq/framework/blob/f0e45f1e4490592dff4aa476f7d553fca77e8b39/src/tty.ts#L21
(In a sense, isTty
is poorly named.)
I suppose we should add isStdinTty
and isStdoutTty
(I'd keep a isTty
that is equal to isStdinTty && isStdoutTty
too).
My point was more that we should push this up the stack, and leverage the effect system instead of doing it at import time.
@mythmon I've tried a different approach, hopefully closer to what you had in mind?
closes #1447 closes #1446
I'm not happy that I had to make c8 specifically ignore the non-coverage of the non-tty output tests, but I did not find a better way.(solved in the new approach, see below)