gulp: gulp.watch stops watching files after first detection

After the first modification to index.html, gulp.watch will stop detecting changes to the file. This issue does not exist for me on 3.9.1.


gulp.task('watch', watch);

function reloadBrowserSync(cb) {
  console.log('sssssssssssssssss');
  cb();
}

function watch(done) {
  gulp.watch(['/home/one/github/one-drop/src/index.html',
             '/home/one/github/one-drop/src/app/**/*.html'], reloadBrowserSync);
}
one@development ~/github $ node --version
v4.2.2
one@development ~/github $ npm --version
2.14.7
one@development ~/github/drop $ gulp -v
[15:11:54] CLI version 1.2.2
[15:11:54] Local version 4.0.0-alpha.2

Reference issue 1783

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 17 (9 by maintainers)

Most upvoted comments

@joelwallis, i’ve tried, but found the solution in other issues.

added the done parameter and called back at the end.

gulp.task(“reload”, (done) => { browserSync.reload(); done(); }); gulp.task(“js:watch”, () => gulp.watch(“lib/**/*.js”, gulp.series(“js”, “reload”)));

@contract and as I noted, the other person that jumped in this thread isn’t using gulp 4…

@alexisdiel thanks for that!

sorry, this isn’t a bug since gulp 3.9.1 does not have this issue with the same exact code?