You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Many long-running sf commands use a beautiful, dynamic output for streaming live updates to the user's TTY. This is fantastic UX, as long as the user TTY is the final output.
However, trying to pipe or redirect that output reveals a mess of control characters that clogs up downstream pipelines.
Use Node's tty.isatty function to determine whether the output environment supports streaming responses. If it does not, do not send dynamic outputs. Only write the final result to the screen.
Mitigations/Workarounds
Set the SF_CONTENT_TYPE=JSON environment variable. This is undesirable because I want a human-readable snapshot of the final result for downstream processing, not a JSON dump.
Use hacks to process stdout as it streams in. (Let me know if you find a function that works!
Leverage stdout vs stdin to selectively render non-TTY and TTY outputs. This works for failures, but will always come up empty with successes.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Problem
Many long-running
sfcommands use a beautiful, dynamic output for streaming live updates to the user's TTY. This is fantastic UX, as long as the user TTY is the final output.However, trying to pipe or redirect that output reveals a mess of control characters that clogs up downstream pipelines.
See raw output
Recommended Solution
Use Node's
tty.isattyfunction to determine whether the output environment supports streaming responses. If it does not, do not send dynamic outputs. Only write the final result to the screen.Mitigations/Workarounds
SF_CONTENT_TYPE=JSONenvironment variable. This is undesirable because I want a human-readable snapshot of the final result for downstream processing, not a JSON dump.Related Discussions
All reactions