I just tried to replace the gulp-add-src plugin with the new feature that was added in 3.8.0, but am getting the error listed below. The code looks like this, simplified:
gulp.task('publish', function() {
gulp.src([ 'package.json', 'component.json' ])
.pipe(bump({ version: options.version }))
.pipe(gulp.dest('./'))
.pipe(gulp.src([ 'dist/*' ]))
.pipe(git.add())
.pipe(git.commit('Release version ' + options.version));
}
});
As you can see, I use two plugins: gulp-bump to change the version numbers in two JSON files, then I add the dist folder to the sources and use gulp-git after to commit all these files together.
I don't understand the internals, but the source to gulp-add-src is extremely simple and the issue does not occur there, so perhaps that's a place to start looking:
https://github.com/urish/gulp-add-src/blob/master/index.js
Or am I just doing it wrong? I am new to Gulp, still learning the Gulp way... : )
stream.js:74
throw er; // Unhandled stream error in pipe.
^
Error: write after end
at writeAfterEnd (/Users/lehni/Development/JavaScript/paper.js/node_modules/gulp/node_modules/vinyl-fs/node_modules/through2/node_modules/readable-stream/lib/_stream_writable.js:144:12)
at DestroyableTransform.Writable.write (/Users/lehni/Development/JavaScript/paper.js/node_modules/gulp/node_modules/vinyl-fs/node_modules/through2/node_modules/readable-stream/lib/_stream_writable.js:192:5)
at DestroyableTransform.ondata (stream.js:31:26)
at emitOne (events.js:77:13)
at DestroyableTransform.emit (events.js:169:7)
at DestroyableTransform.<anonymous> (/Users/lehni/Development/JavaScript/paper.js/node_modules/gulp/node_modules/vinyl-fs/node_modules/through2/node_modules/readable-stream/lib/_stream_readable.js:786:14)
at emitNone (events.js:67:13)
at DestroyableTransform.emit (events.js:166:7)
at emitReadable_ (/Users/lehni/Development/JavaScript/paper.js/node_modules/gulp/node_modules/vinyl-fs/node_modules/through2/node_modules/readable-stream/lib/_stream_readable.js:448:10)
at emitReadable (/Users/lehni/Development/JavaScript/paper.js/node_modules/gulp/node_modules/vinyl-fs/node_modules/through2/node_modules/readable-stream/lib/_stream_readable.js:444:5)
Return your stream...
Ouch, apologies for not spotting that, and thanks for the super quick answer! But unfortunately that didn't solve the issue, it still happens even with the stream returned...
Could it be that .pipe(gulp.dest('./')) is the cause? Can I do this, and then add more with another call to .pipe(gulp.src()) and carry on? If all plugins act on buffered content and not on persisted files, that should work, right?
The gulp.src being able to be used as a passthrough stream wasn't added in 3.8, it was added in vinyl-fs 1.0.0, a newer version of which will end up in gulp 4. If you upgrade to gulp 4, you have to add { passthrough: true } as the 2nd argument to gulp.src() to get a through stream back.
I see, thanks for clarifying. But then this information in the changelog is quite missleading:
https://github.com/gulpjs/gulp/blob/master/CHANGELOG.md#380
This is now possible!
Most helpful comment
I see, thanks for clarifying. But then this information in the changelog is quite missleading:
https://github.com/gulpjs/gulp/blob/master/CHANGELOG.md#380
3.8.0
This is now possible!