Capturing adb push progress output

Viewed 309

I'm trying to capture adb push progress percentage from a node script. I have tried to listen to stdout and stderr but it seems adb is not sending the percentage update to any of these streams. I have seen other old answers in SO about adding a progressbar in terminal and have tried to adapt their methods to my needs, but it seems they are not working anymore.

This is how I'm trying to do it from node. I think a command line solution would be nice too because I could translated easily to node.

    var spawn = window.require('child_process').spawn;
    const ls = spawn('adb', ['push', '/Users/juanjoseduran/Downloads/app-debug.apk',"2>&1", '/sdcard']);

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

    ls.stderr.on('data', function (data) {
        console.log('stderr: ' + data.toString());
    });
    
    ls.on('exit', function (code) {
        console.log('child process exited with code ' + code.toString());
    });

The handlers only trigger when the transfer is finished.

1 Answers

I have had the same issue, i actually needed to downgrade to v29 platform tools, but i think the output only goes to the console, not stdout. I know for a fact that v28 outputs progress data to stdout.

Edit: I'm on a windows machine, not sure if this would transfer to linux.

Edit3: I tried the latest platform-tools for v30 and v31. Not getting PowerShell to display a progress indicator for these. platform-tools v29 outputs to console, not to stdout. v28 outputs to stdout.

Related