Node.js child_process STDOUT not showing progressbar

Viewed 29

I've a problem with displaying the progressbar of a process executed by child_process spawn in a discord bot.

CLI Output:

2021-09-16 16:11:03  Welcome to Minecraft Overviewer version 0.17.39 (2402e41)!
2021-09-16 16:11:03  Generating textures...
2021-09-16 16:12:52  Preprocessing...
2021-09-16 16:15:14  Rendering 228498 total tiles.
 99%     [===================================================================================================================================================================================================== ] 228494 17.65t/s eta 00h 00m 00s
2021-09-16 19:50:57  Rendering complete!

When using the child_process spawn I get every output except for the progressbar.

Node script:

const child_process = require('child_process');
const command       = "python";
const arguments     = ["./Minecraft-Overviewer/overviewer.py", "--config=./world.py"]

var child = child_process.spawn(command, arguments, {
    encoding: 'utf8',
    shell: true
});

child.on('error', (error) => {
    message.channel.send('Error!\r\n' + error);
});

child.stdout.setEncoding('utf8');
child.stdout.on('data', (data) => {
    data    = data.toString();
    message.channel.send(`STDOUT: ${data}`);
});

child.stderr.setEncoding('utf8');
child.stderr.on('data', (data) => {
    message.channel.send(`DATA: ${data}`);
});

child.on('close', (code) => {
    //Here you can get the exit code of the script  
    switch (code) {
        case 0:
            message.channel.send('Process exited.');
            break;
    }
});

Any ideas on how I can catch the progressbar as well? Many thanks in advance!

0 Answers
Related