execa icon indicating copy to clipboard operation
execa copied to clipboard

Getting output from cmd live (uploadbar)

Open ramonbrooks456 opened this issue 3 years ago • 1 comments

I have a cmd script that uploads a file to cloud drive(mega). when i run the file using command prompt i can get upload status a bar,file size uploaded,file size remaining etc. I ran the same command using execa it uploads the file and gets final output like upload finished but not the progress bar.

Is there any way to get progress bar in terminal when i run the script in node?

the code i used is this

const data = await execa("file-name",{shell:true,all:true}).stdout.pipe(process.stdout);

ramonbrooks456 avatar Jul 01 '22 16:07 ramonbrooks456

Hi @ramonbrooks456,

The await execution should be this instead (see example):

const childProcess = execa("file-name", { shell:true, all:true })
childProcess.stdout.pipe(process.stdout)
const result = await childProcess

Also, if you want to redirect both stdout and stderr, you should use childProcess.all and result.all:

const childProcess = execa("file-name", { shell:true, all:true })
childProcess.all.pipe(process.stdout)
const { all: data } = await childProcess

ehmicky avatar Jul 15 '22 14:07 ehmicky