javascript - GULP tap.js - cannot read property -


i've strated using gulp building. i've run wall, while attempting run "scripts" cleaning.

the error

d:\github\asgard\basethemev2\src>gulp default [23:13:03] using gulpfile d:\github\asgard\basethemev2\src\gulpfile.js [23:13:03] starting 'lint:js'... [23:13:03] starting 'build:plugins'... [23:13:03] starting 'build:js'... [23:13:03] starting 'build:less'... [23:13:03] starting 'build:images'... [23:13:03] starting 'build:svgs'... [23:13:03] starting 'build:fonts'... [23:13:03] starting 'build:favicon'... [23:13:03] finished 'build:favicon' after 2.19 ms [23:13:03] finished 'build:plugins' after 78 ms d:\github\asgard\basethemev2\src\node_modules\gulp-tap\lib\tap.js:60     if (obj instanceof basestream && !obj._readablestate.ended) {                                                         ^  typeerror: cannot read property 'ended' of undefined     @ destroyabletransform.modifyfile (d:\github\asgard\basethemev2\src\node_modules\gulp-tap\lib\tap.js:60:57)     @ destroyabletransform.transform._read (d:\github\asgard\basethemev2\src\node_modules\through2\node_modules\readable-stream\lib\_stream_transform.js:182:10)     @ destroyabletransform.transform._write (d:\github\asgard\basethemev2\src\node_modules\through2\node_modules\readable-stream\lib\_stream_transform.js:170:83)     @ dowrite (d:\github\asgard\basethemev2\src\node_modules\through2\node_modules\readable-stream\lib\_stream_writable.js:406:64)     @ writeorbuffer (d:\github\asgard\basethemev2\src\node_modules\through2\node_modules\readable-stream\lib\_stream_writable.js:395:5)     @ destroyabletransform.writable.write (d:\github\asgard\basethemev2\src\node_modules\through2\node_modules\readable-stream\lib\_stream_writable.js:322:11)     @ destroyabletransform.ondata (d:\github\asgard\basethemev2\src\node_modules\through2\node_modules\readable-stream\lib\_stream_readable.js:612:20)     @ emitone (events.js:96:13)     @ destroyabletransform.emit (events.js:188:7)     @ addchunk (d:\github\asgard\basethemev2\src\node_modules\through2\node_modules\readable-stream\lib\_stream_readable.js:284:12)  d:\github\asgard\basethemev2\src> 

the gulp "command" i'm using is believe error ".pipe(tap(function (file, t) {" -- don't know how "not" use this.

// lint, minify, , concatenate scripts gulp.task('build:js',  function() {     var jstasks = lazypipe()         .pipe(header, banner.full, { package : package })         .pipe(gulp.dest, paths.scripts.output)         .pipe(rename, { suffix: '.min' })         .pipe(uglify)         .pipe(header, banner.min, { package : package })         .pipe(gulp.dest, paths.scripts.output);      return gulp.src(paths.scripts.input)         .pipe(plumber())         .pipe(tap(function (file, t) {             if ( file.isdirectory() ) {                 var name = file.relative + '.js';                 return gulp.src(file.path + '/*.js')                     .pipe(concat(name))                     .pipe(jstasks());             }         }))         .pipe(jstasks()); }); 

the problem in line of code:

if (obj instanceof basestream && !obj._readablestate.ended) {   obj.on('end', next);   return obj.on('data', data = function() {     obj.removelistener('end', next);     obj.removelistener('data', data);     return next();   }); } else {   return next(); } 

there no property _readablestate in obj therefore when try read ended error. little googling able land similar issue discussed on github, confirms indeed _readablestate not must in streams.

streams not required have _readablestate state property. if implementation inherits stream.readable, otherwise there no such guarantee.

if head on to node.js docs discover there several types of streams:

there 4 fundamental stream types within node.js:

  • readable - streams data can read (for example fs.createreadstream()).
  • writable - streams data can written (for example fs.createwritestream()).
  • duplex - streams both readable , writable (for example net.socket).
  • transform - duplex streams can modify or transform data written , read (for example zlib.createdeflate()).

back code, obj return in callback:

obj = lambda(inst.file, utils(this, inst.file), inst); 

namely:

return gulp.src(file.path + '/*.js')     .pipe(concat(name))     .pipe(jstasks()); 

is stream, not readable stream? if code fail.

gulp uses vinyl streams , need convert "normal" stream. gulp plugin seems job.

p.s. suggest have @ examples tap provides, sure need return stream in case?


Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -