G
G
gaphest2016-08-02 13:23:29
css
gaphest, 2016-08-02 13:23:29

How to make sure that the task in GULP does not crash when CSSComb fails?

In gulpfile.js
gulp.task('sass', function(){
return gulp.src('app/sass/**/*.+(scss|sass)')
.pipe(sass().on('error ', sass.logError))
.pipe(gulp.dest('app/css'))
.on('error', sass.logError)
.pipe(browserSync.reload({stream: true}));
});
task csscomb'a
gulp.task('stylesass', function() {
return gulp.src('app/sass/*.scss')
.pipe(csscomb())
.pipe(gulp.dest('app/sass' ));
});
create my task
gulp.task('watch',['browser-sync','sass','css-libs', 'scripts', 'styles'],
]); // Watch scss|sass files and call sass task and stylesass(csscomb) if they change
gulp.watch('app/*.html', browserSync.reload);
gulp.watch('app/js/**/*.js', browserSync.reload);
});
So, if csscomb thinks that there is an error in the sass file (and it thinks so right while editing the sass file, if we don’t have time to add a value to the parameter ( padding: ;))
then my watch task is interrupted and it has to be started again. How to make it so that it just writes an error but does not stop the task

Answer the question

In order to leave comments, you need to log in

2 answer(s)
K
Kirill Kublyakov, 2016-08-02
@Kublyakov

As far as I know, everyone uses https://www.npmjs.com/package/gulp-plumber for this

K
Konstantin Basharkevich, 2016-08-02
@qodunpob

let gutil = require('gulp-util');
...
.pipe(csscomb().on('error', function (e) {
    gutil.log(gutil.colors.red(e.message));
    this.emit('end');
}))

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question