Yarn: No fancy terminal features when stdout not a tty

Created on 11 Oct 2016  路  13Comments  路  Source: yarnpkg/yarn

Do you want to request a _feature_ or report a _bug_?
Feature

What is the current behavior?
Color escape codes and progress bars are always output, regardless of whether stdout is a TTY.

If the current behavior is a bug, please provide the steps to reproduce.
To reproduce easily, yarn | more. Note the escape codes being printed literally.

What is the expected behavior?
When the output of yarn is redirected, do not use color escapes. Likely, the output is going to be processed in some way. Check process.stdout.isTTY() (see https://nodejs.org/api/tty.html#tty_tty for example), before outputting color, doing fancy spinners or progress bars.

Please mention your node.js, yarn and operating system version.
node.js: v6.7.0
yarn: 0.15.1
OS: OSX 10.12

Most helpful comment

+1 Also it would be great to have a command line option to force this behaviour :)

All 13 comments

+1 Also it would be great to have a command line option to force this behaviour :)

--no-color possibly?

For CI, it would be great to have a really quiet option that emits trace only on failures (and without control codes).

yarn -q ...... # quiet mode

Generally you want CI output to be very easy to scan for errors and warnings. Control codes and verbose output make this much harder.

@sensedeep For the quiet mode, you can see #788 and for the command line option I think #1340 covers it :)

So this issue can be closed I think!

Just tried that in 0.16.1. Seems --silent is not released yet?

 yarn --silent install

  error: unknown option `--silent'

yarn --no-progress install

  error: unknown option `--no-progress'

@sensedeep #788 is not closed so no :)

The ability to both suppress progress logs and control codes would be great, as it鈥檚 making my Viaduct deployment logs look _hideous_:

screen shot 2016-10-26 at 09 32 51

If this is to be a drop-in replacement for npm, then it should have the user options npm offer.

Should be fixed with --no-progress (#1190), please reopen if that's not enough.

This seems to still be a problem:

jrr@jrrmbp ~> yarn versions |more
yarn versions v1.9.4
{ yarn: ESC[32m'1.9.4'ESC[39m,
  http_parser: ESC[32m'2.8.0'ESC[39m,
  node: ESC[32m'8.11.3'ESC[39m,
  v8: ESC[32m'6.2.414.54'ESC[39m,
  uv: ESC[32m'1.19.1'ESC[39m,
  zlib: ESC[32m'1.2.11'ESC[39m,
  ares: ESC[32m'1.10.1-DEV'ESC[39m,
  modules: ESC[32m'57'ESC[39m,
  nghttp2: ESC[32m'1.32.0'ESC[39m,
  napi: ESC[32m'3'ESC[39m,
  openssl: ESC[32m'1.0.2o'ESC[39m,
  icu: ESC[32m'60.1'ESC[39m,
  unicode: ESC[32m'10.0'ESC[39m,
  cldr: ESC[32m'32.0'ESC[39m,
  tz: ESC[32m'2017c'ESC[39m }
Done in 0.02s.

@arcanis , as @jrr mentioned, this _does_ seem to still be a problem. I get the same output he showed, even when doing yarn versions --no-progress.

We would appreciate a PR.

As much as I'd love to send a PR, it's doubtful I will have time. Would you consider re-opening the issue?

Not this one, the original issue is super old, and it's unclear the one you reported is the same as the one originally referenced (I suspect the problem here is that we're using require('util').inspect).

You can however create a new one, which will make it easier from anyone willing to fix the issue to extract the needed information 馃檪

Was this page helpful?
0 / 5 - 0 ratings