Allow use of failOnError with Stream-based input #1691

This commit is contained in:
Lovell Fuller 2019-06-26 19:37:27 +01:00
parent 631a3597c7
commit 628996846d
3 changed files with 12 additions and 2 deletions

View File

@ -9,7 +9,10 @@ Requires libvips v8.8.0.
* Remove `overlayWith` previously deprecated in v0.22.0.
* Drop support for Node.js versions 6 and 11.
[#1212](https://github.com/lovell/sharp/issues/1674)
[#1674](https://github.com/lovell/sharp/issues/1674)
* Allow use of failOnError option with Stream-based input.
[#1691](https://github.com/lovell/sharp/issues/1691)
### v0.22 - "*uptake*"

View File

@ -19,7 +19,7 @@ function _createInputDescriptor (input, inputOptions, containerOptions) {
} else if (is.plainObject(input) && !is.defined(inputOptions)) {
// Plain Object descriptor, e.g. create
inputOptions = input;
if (is.plainObject(inputOptions.raw)) {
if (is.plainObject(inputOptions.raw) || is.bool(inputOptions.failOnError)) {
// Raw Stream
inputDescriptor.buffer = [];
}

View File

@ -1,6 +1,7 @@
'use strict';
const assert = require('assert');
const fs = require('fs');
const sharp = require('../../');
const fixtures = require('../fixtures');
@ -72,4 +73,10 @@ describe('failOnError', function () {
done(err.message.includes('VipsJpeg: Premature end of JPEG file') ? undefined : err);
});
});
it('handles stream-based input', function () {
const writable = sharp({ failOnError: false });
fs.createReadStream(fixtures.inputJpgTruncated).pipe(writable);
return writable.toBuffer();
});
});