New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Monkey patching `pipe` method from gulp.src #91

Closed
floatdrop opened this Issue Jan 5, 2014 · 6 comments

Comments

Projects
None yet
4 participants
@floatdrop
Contributor

floatdrop commented Jan 5, 2014

In continue from this issue and summed up thoughts about error handling in gulp here is possible solution. Monkey patch pipe method from gulp.src in such a way, that it will monkey patch other streams, when you call pipe on them. This will allow fix pipe behaviour, that unpipes destanation stream on error.

Here is proposed options to gulp.src:

unpipeOnError [Boolean]
Don't remove ondata listener in destination stream on error. This option inherits on all streams in pipeline.

logOnError: [Boolean, String]
Little helper, that cleans up copy-pasted on('error', gutil.log) code. It will log errors that prefixed by passed string.

Example of usage:

gulp.src('coffee/**/*.coffee', { unpipeOnError: false, logOnError: true })
  .pipe(gulpPrefixer('// Copyright 2014 (C) Aswesome company'))
  .pipe(coffee())
  .pipe(gulp.dest('js/'));

Also it will be nice to have unpipeOnError option inside a pipe function to allow partially soft pipelines:

gulp.src('coffee/**/*.coffee', { logOnError: true })
  .pipe(gulpPrefixer('// Copyright 2014 (C) Aswesome company'))
  .pipe(coffee(), { unpipeOnError: false })
  .pipe(gulp.dest('js/'));
@contra

This comment has been minimized.

Show comment
Hide comment
@contra

contra Jan 5, 2014

Member

This seems overcomplicated...

Member

contra commented Jan 5, 2014

This seems overcomplicated...

@dashed

This comment has been minimized.

Show comment
Hide comment
@dashed

dashed Jan 5, 2014

Contributor

I'm for logOnError: true or logOnError: gutil.log config option.

I'm little unclear on how unpipeOnError resolves the issues mentioned in your gist. I haven't looked extensively under the hood of node.js streams.

Contributor

dashed commented Jan 5, 2014

I'm for logOnError: true or logOnError: gutil.log config option.

I'm little unclear on how unpipeOnError resolves the issues mentioned in your gist. I haven't looked extensively under the hood of node.js streams.

@floatdrop

This comment has been minimized.

Show comment
Hide comment
@floatdrop

floatdrop Jan 6, 2014

Contributor

This issue affecting gulp-watch as well, if error occured in plugin - this plugin will be unpiped from source and will not be receiving vinyl files.

Contributor

floatdrop commented Jan 6, 2014

This issue affecting gulp-watch as well, if error occured in plugin - this plugin will be unpiped from source and will not be receiving vinyl files.

@floatdrop

This comment has been minimized.

Show comment
Hide comment
@floatdrop

floatdrop Jan 6, 2014

Contributor

I published gulp-plumber which will contain some "pipe-helpers". For now it only fixes unpiping behaviour on all streams, that are down the pipeline.

var gulp = require('gulp'),
    watch = require('gulp-watch'),
    plumber = require('gulp-plumber'),
    sass = require('gulp-sass');

gulp.task('default', function () {
    gulp.src('scss/**', { read: false })
        .pipe(watch())
        .pipe(plumber())
        .pipe(sass())
        .pipe(gulp.dest('./dist/'));
});
Contributor

floatdrop commented Jan 6, 2014

I published gulp-plumber which will contain some "pipe-helpers". For now it only fixes unpiping behaviour on all streams, that are down the pipeline.

var gulp = require('gulp'),
    watch = require('gulp-watch'),
    plumber = require('gulp-plumber'),
    sass = require('gulp-sass');

gulp.task('default', function () {
    gulp.src('scss/**', { read: false })
        .pipe(watch())
        .pipe(plumber())
        .pipe(sass())
        .pipe(gulp.dest('./dist/'));
});

@floatdrop floatdrop closed this Jan 6, 2014

@dashed

This comment has been minimized.

Show comment
Hide comment
@dashed

dashed Jan 6, 2014

Contributor

gulp-plumber works pretty well. People using this, however, should be aware of plugins using es.map.

Contributor

dashed commented Jan 6, 2014

gulp-plumber works pretty well. People using this, however, should be aware of plugins using es.map.

@tennessine

This comment has been minimized.

Show comment
Hide comment
@tennessine

tennessine commented Apr 26, 2015

thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment