Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Excluding subdirectory from gulp-watch throwing type error

I'm running the following watch task:

gulp.task('watch', function() {

    gulp.watch('./ui/scss/*.scss', ['styles']);
    gulp.watch('./js/*.js', '!./js/vendor/*.js', ['scripts']);
    gulp.watch('./**/*.html', ['html']);

});

But it seems to throw the following error?...

TypeError: Cannot assign to read only property 'mark' of !./js/vendor/*.js at new Gaze
like image 210
jx3 Avatar asked Aug 15 '15 08:08

jx3


2 Answers

You need brackets around the paths if you want to specify multiple. Try the following for your second watch:

gulp.watch(['./js/*.js', '!./js/vendor/*.js'], ['scripts']);

gulp.watch handles the file argument the same as vinyl-fs. So you can use all the features specified in their documentation in gulp.watch as well.

like image 128
Patrick Kostjens Avatar answered Nov 16 '22 13:11

Patrick Kostjens


the second parameter of the watch must declare as array

gulp.watch('src...', ['taskname', ......];
like image 36
Mohammad Avatar answered Nov 16 '22 13:11

Mohammad