Skip to content
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

Stop .pipe() chain on linting error? #102

Open
dryoma opened this issue Jan 21, 2016 · 0 comments
Open

Stop .pipe() chain on linting error? #102

dryoma opened this issue Jan 21, 2016 · 0 comments

Comments

@dryoma
Copy link

dryoma commented Jan 21, 2016

I'm trying to make gulp-jscs run on file changes, and - if an error is encountered - just report it, without breaking watch and without continuing the stream (e.g., a file with errors doesn't get uglified and doesn't go to a dest folder). And can't seem to succeed in both with gulp-jscs: either the fail (and failImmediage) reporter breaks watch, or, if I catch stream errors, the stream doesn't stop.

I should note that if the error handler is attached after the call to, for example, gulp-uglify, it works as it should: there is no throw and the stream doesn't continue.

Am I right to assume that it's gulp-jscs that is unable to do what I need it to do? And if so, is there a way to fix this?

gulp v3.9.0, gulp-jscs v3.0.2, the gulpfile looks like this:

var gulp = require('gulp'),
    jscs = require('gulp-jscs'),
    uglify = require('gulp-uglify');

gulp.task('js', function(){
    gulp.src('js/*.js')
        .pipe(jscs())
        .pipe(jscs.reporter())
        .pipe(jscs.reporter('failImmediately'))
        .on('error', function(e){
            this.emit('end');
        })
        .pipe(uglify()) // This should (and everything after) not fire if jscs finds an error. But it does.
        .pipe(gulp.dest('dist/js/'));
});

gulp.task('default', function(){
    gulp.watch('js/*.js', ['js'])
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant