node-progress icon indicating copy to clipboard operation
node-progress copied to clipboard

Progress bar doesn't show at child_process spawn

Open MikeDevice opened this issue 7 years ago • 2 comments

Here is two files

test.js

var ProgressBar = require('progress');

var bar = new ProgressBar(':bar', { total: 10 });

console.log('ProgressBar');
var timer = setInterval(function () {
  bar.tick();
  if (bar.complete) {
    clearInterval(timer);
  }
}, 100);

index.js

var spawn = require('child_process').spawn;

var ls = spawn('node', ['./test.js']);

ls.stdout.on('data', function(data) {
  console.log(data.toString());
});

If run $ node test.js , progress bar will be rendered, but if run $ node index.js — won't.

MikeDevice avatar Jun 10 '17 22:06 MikeDevice

By default this writes to the stderr stream. Did you try stderr instead of stdout?

DesignByOnyx avatar Jan 03 '18 21:01 DesignByOnyx

You should try to use 'child-process-promise' instead 'child_process', so you can success.

fredgan avatar Dec 02 '20 02:12 fredgan

Progress bar uses by default as strem the stderr, check here.

Can you try using in options the standard output?

var bar = new ProgressBar(':bar', { total: 10, stream: process.stdout });

jfoclpf avatar Nov 24 '22 10:11 jfoclpf