Я очень новичок в Gulp
и его библиотеках. Я только что увидел пост в StackOverflow о написании функции канала с использованием JavaScript внутри gulpfile.js. Я попытался поэкспериментировать с ним, написав очень короткую трубу, полученную из WriteStream
:
var gulp = require('gulp');
var connect = require('gulp-connect');
var PATHS = {
src: 'src/**/*.ts',
html: 'src/**/*.html',
css: 'src/**/*.css'
};
var stream = require('stream');
//var map = require('map-stream');
var writable = new stream.Writable({
write: function(chunk, encoding, next) {
console.log(chunk.toString());
next();
}
});
gulp.task('test', function() {
var test = gulp.src(PATHS.src);
gulp.src(PATHS.src)
.pipe(writable);
});
Это дает мне, однако, следующую ошибку, которую я не понимаю:
(node:5396) ExperimentalWarning: The http2 module is an experimental API.
[13:28:25] Starting 'test'...
[13:28:25] Finished 'test' after 7.12 ms
events.js:183
throw er; // Unhandled 'error' event
^
TypeError: Invalid non-string/buffer chunk
at validChunk (_stream_writable.js:254:10)
at Writable.write (_stream_writable.js:288:21)
at write (C:\AngularIBought\angular2byexample-base\trainer\node_modules\vinyl-fs\node_modules\readable-stream\lib\_stream_readable.js:623:24)
at flow (C:\AngularIBought\angular2byexample-base\trainer\node_modules\vinyl-fs\node_modules\readable-stream\lib\_stream_readable.js:632:7)
at DestroyableTransform.pipeOnReadable (C:\AngularIBought\angular2byexample-base\trainer\node_modules\vinyl-fs\node_modules\readable-stream\lib\_stream_readable.js:664:5)
at emitNone (events.js:106:13)
at DestroyableTransform.emit (events.js:208:7)
at emitReadable_ (C:\AngularIBought\angular2byexample-base\trainer\node_modules\vinyl-fs\node_modules\readable-stream\lib\_stream_readable.js:448:10)
at emitReadable (C:\AngularIBought\angular2byexample-base\trainer\node_modules\vinyl-fs\node_modules\readable-stream\lib\_stream_readable.js:444:5)
at readableAddChunk (C:\AngularIBought\angular2byexample-base\trainer\node_modules\vinyl-fs\node_modules\readable-stream\lib\_stream_readable.js:187:9)
Что не так с моим кодом?
С Уважением,
Януш