Firstly, here is a repo with very simple example of my problem: https://github.com/nkoder/example-of-gulp-less-zero-exit-on-error
I want to define gulp build pipeline which fails on any error. This pipeline would be used in automated process (eg. Continuous Integration) so I need the build command to return non-zero exit code on failure. It works for me with invalid Jade templates or non-passing tests run with Karma.
The problem is when I use gulp-less
to prepare CSS from LESS. Whenever I add any pipeline step after gulp-less
execution, all errors are "consumed" and the whole task exits with 0. But it shouldn't.
- The first question is: How to force
wrong
task to fail with non-zero exit code? (solved, see answer below) - The second question is: Why
error
event emitted inless()
call followed by piped stream is not making a whole task to return non-zero exit code? Non-zero is returned in some other similar cases, eg. in Jade or ESLint failure. (not solved yet)
Versions:
- node 5.11.0
- npm 3.8.6
- gulp 3.9.1
- gulp-less 3.1.0