mirror of https://gitgud.io/fatchan/gm
be). But empty buffers are present sometimes if an invoked process returns with an error code. In the current architecture, callback functions can receive streams, which are available before the process exits and delivers an exit code. The callback can thus not be informed of the error condition by the library and has to find out herself. This commit fixes a case when the callback is provided by the library, so that empty streams are reported as errors. - streamToUnemptyBuffer checks the length of the buffer before delivering it, and if the buffer has a zero length, an error is delivered instead. This behavior is probably good for all the cases where streamToBuffer is used in this library, so I'm also dropping that as a dependency. - Added a test case. All tests passing. - Fixes #299master
parent
a5cce8a4b1
commit
48f277b011
3 changed files with 59 additions and 5 deletions
@ -0,0 +1,21 @@ |
||||
var assert = require('assert') |
||||
|
||||
module.exports = function (_, dir, finish, gm) { |
||||
var svg_file; |
||||
svg_file = new Buffer('<svg viewBox="0 0 20 17" style="background-color:#ffffff00" xmlns="http://www.w3.org/2000/svg" width="20" height="17"><g fill="#656C72"><path d="M0 0h20v3h-20zM0 7h20v3h-20zM0 14h20v3h-20z"/></g></svg>', 'ascii'); |
||||
|
||||
// The following invocation should fail, because 'convert'
|
||||
// has no way of interpreting the file.
|
||||
gm( |
||||
svg_file,
|
||||
'./test.svg' // fiction
|
||||
).options({ |
||||
imageMagick: true |
||||
}).setFormat('png').toBuffer(function(err, buffer) { |
||||
assert.ok(err, "Expecting error on this buffer"); |
||||
}); |
||||
|
||||
if (!gm.integration) |
||||
return finish(); |
||||
|
||||
} |
Loading…
Reference in new issue