node.js - es.merge usage in gulp: Object #<Stream> has no method 'end' -
i struggling 2 parallel processing routes work in gulp. code looks this:
gulp.task('build', function(){ return gulp.src(src,{cwd:srcdir}) .pipe(concat('sdk.js', {newline:'\n\n'})) .pipe(gulp.dest('dist/')) .pipe(jshint()) .pipe(jshint.reporter('default')) .pipe(es.merge( gulp.src('dist/sdk.js') .pipe(preprocess({context:{debug:true}})) .pipe(rename('sdk.debug.js')), gulp.src('dist/sdk.js') .pipe(preprocess({context:{}})) .pipe(uglify()) .pipe(rename('sdk.min.js')) )) //some more processing .pipe(gulp.dest('dist/')) ; });
i have found suggestion here such way of forking , merging streams should work. however, error:
stream.js:79 dest.end(); ^ typeerror: object #<stream> has no method 'end' @ stream.onend (stream.js:79:10) @ stream.eventemitter.emit (events.js:117:20) @ end (c:\users\user\documents\proj\node-sdk\node_modules\gulp- jshint\node_modules\map-stream\index.js:116:39) @ stream.stream.end (c:\users\user\documents\proj\node-sdk\node _modules\gulp-jshint\node_modules\map-stream\index.js:122:5) @ stream.onend (stream.js:79:10) @ stream.eventemitter.emit (events.js:117:20) @ end (c:\users\user\documents\proj\node-sdk\node_modules\gulp- jshint\node_modules\map-stream\index.js:116:39) @ queuedata (c:\users\user\documents\proj\node-sdk\node_modules \gulp-jshint\node_modules\map-stream\index.js:62:17) @ next (c:\users\user\documents\proj\node-sdk\node_modules\gulp -jshint\node_modules\map-stream\index.js:71:7) @ c:\users\user\documents\proj\node-sdk\node_modules\gulp-jshin t\node_modules\map-stream\index.js:85:7
it seems problem lies usage of es.merge, without (one processing path) works expected. unfortunately, don't have extensive knowledge of node.js streams, cannot identify cause of problem. version of node 0.10.28, gulp 3.6.2 , event-stream 3.1.5
es.merge
cannot used target of pipe because not proper writestream. implements write()
not end()
work forward along incoming stream data, when upstream source finished, es.merge
not handle end
event. don't know if intended behavior es.merge
, @ least in current implementation, can used source.
https://github.com/dominictarr/event-stream/blob/master/index.js#l32
an alternate solution split task 2 separate tasks , use gulp dependencies:
gulp.task('build-concat', function() { return gulp.src(src,{cwd:srcdir}) .pipe(concat('sdk.js', {newline:'\n\n'})) .pipe(gulp.dest('dist/')) .pipe(jshint()) .pipe(jshint.reporter('default')); }); gulp.task('build', ['build-concat'], function() { return es.merge( gulp.src('dist/sdk.js') .pipe(preprocess({context:{debug:true}})) .pipe(rename('sdk.debug.js')), gulp.src('dist/sdk.js') .pipe(preprocess({context:{}})) .pipe(uglify()) .pipe(rename('sdk.min.js')) )) //some more processing .pipe(gulp.dest('dist/')) ; });
Comments
Post a Comment