3

I am getting different results for different gulp.watch instruction When I execute my watch task and change an .html file, everything works correctly (tasks defined below)

But when I change any other files (.coffee, .less, etc) I get this error:

stream.js:94

      throw er; // Unhandled stream error in pipe.
        ^
Error: write after end
  at writeAfterEnd (/Users/oclement/Documents/phoenix/MedifastCerBrokenDown/MedifastWeb/AppSource/node_modules/gulp-filter/node_modules/through2/node_modules/readable-stream/lib/_stream_writable.js:145:12)
  at Transform.Writable.write (/Users/oclement/Documents/phoenix/MedifastCerBrokenDown/MedifastWeb/AppSource/node_modules/gulp-filter/node_modules/through2/node_modules/readable-stream/lib/_stream_writable.js:193:5)
  at Stream.ondata (stream.js:51:26)
  at Stream.emit (events.js:95:17)gulp.watch`

Watch Task

gulp.task('watch', function() {
    isWatching = true;
    run('build', 'index', function() {
        g.util.log(g.util.colors.green('Starting to Watch'));
        gulp.watch('./app/**/*.html', ['templates']);
        gulp.watch('./app/**/*.coffee', ['phnxjs']);
        ...
    });
});

Template Task

gulp.task('templates', function(done) {
    g.util.log(g.util.colors.green('---TEMPLATES---'));
    sourceStreams.templates()
        .pipe(buildWatchPipe()())
        .pipe(g.ngHtml2js(options.templates))
        .pipe(g.concat(destinations.templates.bundleName))
        .pipe(g.if(isProd, transformScriptsProd()))
        .pipe(destinations.templates.target())
        .pipe(g.if(isWatching, g.livereload()));
    done();
});

Phnxjs Task

gulp.task('phnxjs', function(done) {
    g.util.log(g.util.colors.green('---PHNXJS---'));
    var wrapException = g.filter('!**/tags-input.js');

    sourceStreams.phoenixScripts()
        .pipe(buildWatchPipe()())
        .pipe(filters.coffee)
        .pipe(g.coffee(options.coffee))
            .on('error', g.util.log)
        .pipe(filters.coffee.restore())
        .pipe(wrapException)
            .pipe(iffeWrapper())
        .pipe(wrapException.restore())
        .pipe(g.if(!isProd, g.angularFilesort()))
        .pipe(g.if(isProd, transformScriptsProd()))
        .pipe(g.if(isProd, g.concat(destinations.phoenixScripts.bundleName)))
        .pipe(destinations.phoenixScripts.target())
        .pipe(g.if(isWatching, g.livereload()));

    done();
});
JasonMArcher
  • 14,195
  • 22
  • 56
  • 52
Olivier Clément
  • 764
  • 1
  • 8
  • 27
  • 1
    No problem, will delete my answer and re-open it if I see something else – Preview Aug 01 '14 at 18:32
  • Include your filter variable inside of the task. See [How to watch gulp multiple files][1] [1]: http://stackoverflow.com/questions/27645103/how-to-gulp-watch-multiple-files/29617943#answer-29617943 – Lyra Apr 14 '15 at 02:01

0 Answers0