Skip to content

Commit

Permalink
If file doesn't exist, throw an exception
Browse files Browse the repository at this point in the history
  • Loading branch information
drone1 committed Nov 12, 2019
1 parent 4cb8ebb commit 12d675e
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib/render.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
var spawn = require('child_process').spawn
var fs = require('fs')
//var Canvas = require('canvas')

var defaultSetting = {
Expand Down Expand Up @@ -32,6 +33,10 @@ function getPcmData (filename, options, sampleCallback, endCallback) {
sampleRate = options.sampleRate
}

if (!fs.existsSync(filename)) {
throw `File doesn't exist: ${filename}`
}

var ffmpeg = spawn('ffmpeg', ['-i', filename, '-f', 's16le', '-ac', channels,
'-acodec', 'pcm_s16le', '-ar', sampleRate, '-y', 'pipe:1'])

Expand Down Expand Up @@ -161,7 +166,7 @@ module.exports = function render (url, options, cb) {
//canvasContext.fillStyle = options.baselineColor
//canvasContext.fillRect(0, options.baseline - (options.baselineWidth / 2), options.width, options.baselineWidth)
}
cb(null, canvas.toBuffer())
//cb(null, canvas.toBuffer())

if (options.normalizedValuesCallback) {
options.normalizedValuesCallback(normalizedVals);
Expand Down

0 comments on commit 12d675e

Please sign in to comment.