Skip to content

Commit

Permalink
Allow use of failOnError with Stream-based input #1691
Browse files Browse the repository at this point in the history
  • Loading branch information
lovell committed Jun 26, 2019
1 parent 631a359 commit 6289968
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
5 changes: 4 additions & 1 deletion docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -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*"

Expand Down
2 changes: 1 addition & 1 deletion lib/input.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [];
}
Expand Down
7 changes: 7 additions & 0 deletions test/unit/failOnError.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
'use strict';

const assert = require('assert');
const fs = require('fs');

const sharp = require('../../');
const fixtures = require('../fixtures');
Expand Down Expand Up @@ -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();
});
});

0 comments on commit 6289968

Please sign in to comment.