execa
execa copied to clipboard
Getting output from cmd live (uploadbar)
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);
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