gimm / gulp-express

gulp plugin for express
56 stars 26 forks source link

Is server.notify compatible with pipe()? #19

Closed simevidas closed 9 years ago

simevidas commented 9 years ago

I apologize for my ignorance, but I’m not familiar with Gulp’s .pipe() mechanism. I was just wondering if it would be possible to trigger server.notify within a .pipe() call.

As you are already aware, invoking server.notify does not play nice with gulp.watch() leading to code like this:

gulp.watch(['{.tmp,app}/styles/**/*.css'], function(){
    gulp.run('styles:css');
    server.notify(event);
});

How about this alternative approach:

gulp.watch(['/styles/*.css'], ['styles']);

// and then

gulp.task('styles', function () {
    return gulp.src('source/css/*.css')
        // …
        .pipe(gulp.dest('public/css/'))
        .pipe(/* invoke server.notify here somehow */);
});

I’m already using this pattern by using a custom gulp-livereload plugin (see here). I think this approach is more sensical and would love to have it provided by your plugin.

gimm commented 9 years ago

@simevidas pipe support is added for notify, now you can:

gulp.task('styles', function () {
    return gulp.src('source/css/*.css')
        // …
        .pipe(gulp.dest('public/css/'))
        .pipe(server.notify());
});

thanks for your advice!