Closed asselin closed 8 years ago
Can you add a test that fails without this fix?
I can take a crack, but it won't be today.
One way to test this is to pipe useref into a through2 stream that collects the filenames in the transform, and then in the flush function, compares the collected filenames to the list of expected filenames. If the transform function inserts a delay before calling the callback, the files will queue up in useref, and not all of them will be passed to the through2 stream before it's flush is called. To simplify, I'd also configure the through2 stream to have a small buffer (default IIRC is 16) so that you don't have to run useref with input that will create a ton of files.
Thank you. And thanks for pointing this out. I'll take a look as well when I have some time.
I fixed a few things in the PR update:
Note: I also found a similar bug with the additionalStreams option. I'll open a separate bug on that one.
Thanks! Can you squash your commits?
Edit: Before you squash, see my comments below.
Squashed and pushed.
Depending on how much buffering was available in the gulp pipe, some assets would not be sent to the stage of the pipe. Root cause is an error in API usage. emit('end') was being called directly, instead of calling the transform stream's flush callback function.
Fixes #176