progress-bar-webpack-plugin icon indicating copy to clipboard operation
progress-bar-webpack-plugin copied to clipboard

doesn't work in Webstorm run tool

Open urrri opened this issue 8 years ago • 8 comments

I'm not sure this problem is in the package, but it works fine in terminal window and show nothing in "Run" window of Webstorm (I even didn't receive final callback).

urrri avatar Mar 15 '17 05:03 urrri

same to me

weihong1028 avatar Mar 16 '17 15:03 weihong1028

+1

think2011 avatar Apr 18 '17 06:04 think2011

This is because the plugin is disabled if the output is not a TTY, like WebStorm's Run window.

hubgit avatar Oct 05 '17 13:10 hubgit

Here's the upstream discussion in node-progress.

Another library with the same issue (supports-color) fixed this by adding a FORCE_COLOR option.

hubgit avatar Oct 12 '17 10:10 hubgit

The same issue is seen when running an application with forever, which redirects the output to a non-TTY stream.

This workaround helps in that case:

  var stream = options.stream;

  if (!stream) {
    stream = process.stderr;

    if (!stream.isTTY) {
      var tty = require('tty').WriteStream.prototype;

      Object.keys(tty).forEach(function (key) {
        process.stderr[key] = tty[key];
      })

      process.stderr.columns = 80;
    }
  }

Unfortunately WebStorm's Run window doesn't support clearing the line, so keeps drawing new progress bars.

hubgit avatar Oct 12 '17 10:10 hubgit

+1

miniskylab avatar Oct 29 '17 19:10 miniskylab

I made it work perfectly in Webstorm's run console (on Windows 10) by adding this TTY-mock before using the progress bar:

if (!process.stdout.isTTY) {
    process.stdout.isTTY = true;
    process.stdout.columns = 80;
    process.stdout.cursorTo = () => { process.stdout.write('\r') };
    process.stdout.clearLine = () => {};
}

And creating the ProgressBar with the option "stream: process.stdout"

The mocked cursorTo()-function enables overwriting the same line so that multiple lines are not rendered (at least on Windows, this must done before writing the actual line, so that's why process.stdout.write('\r') is put in cursorTo() and not in clearLine()))

TobbeLino avatar Apr 03 '18 17:04 TobbeLino

+1

ruaneg avatar Apr 19 '18 10:04 ruaneg