Skip to content

Commit

Permalink
fix: throw child process errors
Browse files Browse the repository at this point in the history
  • Loading branch information
abdulrahman1s committed Nov 20, 2022
1 parent 4b47d98 commit b24fdb0
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/util/ffmpeg.js
Original file line number Diff line number Diff line change
Expand Up @@ -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())
})

0 comments on commit b24fdb0

Please sign in to comment.