Closed klausbayrhammer closed 8 years ago
All errors are passed from stylus into gulp, this plugin does not handle anything to do with errors. https://github.com/stevelacy/gulp-stylus/blob/master/index.js#L47
Did you try to reproduce it with the repo I've prepared?
As a workaround we are using an onError handler which stops everything in case of an error. Definitely an ugly solution but at least we catch our stylus errors until this issue is resolved. Besides I would really appreciate if you would reopen the issue, because I don't think it has been resolved.
gulp.task('stylus', function () {
return gulp.src('styles/*.styl')
.pipe(stylus())
.on('error', (err) => {
process.exit(1);
})
.pipe(gulp.dest('target'));
});
gulp plugins are not supposed to handle the errors internally, just pass it to gulp stream. Which will contain the error unless it dies or has an error handler. http://hmphry.com/error-handling-in-gulp-js
gulp v4 will have internal error handling, making the plugin errors much easier to handle
I agree with you that gulp should either break the stream if no error handler is defined or do whatever the error handler specified if defined. The thing with the current solution is, that I have neither an error handler defined nor does the stream break in case of an error - it just logs the error and continues. As a reference the gulp-jade plugin would break the stream if no error handler is defined.
Hi,
Today I stumbled upon a quite weird situation when it comes to handling return codes in gulp-stylus. I have a task which is pretty much like this:
Whenever I have a syntax error in my stylus files, the error is printed out but the return code is 0. It would be extremely helpful if we could return 1 so a (CI-)build knows when to fail. Surprisingly (at least to me), the response code was 1 if the stylus-pipe isn't followed by another pipe
You can check out klausbayrhammer/gulp-stylus-reponse-code where the error is reproduced (and gulp-jade is added as a reference how I would expect the return code to be handled).