writing-a-plugin "Call the callback function only when the current file (stream/buffer) is completely consumed"
What were you expecting to happen?
Following the verbal guidance here -
"Call the callback function only when the current file (stream/buffer) is completely consumed"
then in case of file.IsStream()
I expected to need to wait for the 'end' event from the inner transform before calling the callback()
.
What actually happened?
As shown in the code example on that man page, it only works if callback()
is called immediately.
Please post a sample of your gulpfile (preferably reduced to just the bit that's not working)
innerTransform.on('end', () => {
cb(null, file) // gulp writes an empty file doing it this way
})
Actually implementing the above code (instead of calling the callback
immediately), resulted in an empty file being written, although the inner transform had dutifully pushed all the data.
What version of gulp are you using? gulp 4
What versions of npm and node are you using? npm 6.9.0 gulp 4.0.2
I am unable to convince myself that
when the current file (stream/buffer) is completely consumed
could mean anything other than the end
event has been emitted. Furthermore, the wording seems perfect from a design point of view, and fits with all the usage of callback
s that I know.
How to reconcile the words and the actual design?