From b24fdb07848d97d95f147339558acffe9d3085b4 Mon Sep 17 00:00:00 2001 From: abdulrahman1s <61483023+abdulrahman1s@users.noreply.github.com> Date: Sun, 20 Nov 2022 16:59:41 +0000 Subject: [PATCH] fix: throw child process errors --- src/util/ffmpeg.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/util/ffmpeg.js b/src/util/ffmpeg.js index cd0a805..6e12e9f 100644 --- a/src/util/ffmpeg.js +++ b/src/util/ffmpeg.js @@ -5,11 +5,12 @@ import ffmpegPath from 'ffmpeg-static' export default (args, { silent = false, pipe } = {}) => new Promise((resolve, reject) => { const child = spawn(ffmpegPath, args) let err = '' - + child.stdout.on('data', (data) => silent || console.log(data.toString())) - child.stderr.on('data', (data) => silent || (console.log(data.toString()), err += data.toString())) - + child.stderr.on('data', (data) => (err += data, silent || console.log(data.toString()))) + if (pipe) child.stderr.pipe(pipe) - + + child.on('error', reject) child.on('exit', (code) => code ? reject(err) : resolve()) }) \ No newline at end of file