node-progress
node-progress copied to clipboard
Progress bar doesn't show at child_process spawn
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.
By default this writes to the stderr
stream. Did you try stderr
instead of stdout
?
You should try to use 'child-process-promise' instead 'child_process', so you can success.
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 });