question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

G4 - Watch only running once

See original GitHub issue

Gulp 4 newbie here. I’m having trouble firing off a series of tasks using watch in Gulp 4. Anyone see an issue with this?

gulp.watch(['scripts/**/*.js','!scripts/main.min.js'], gulp.series(buildScripts,reload));

The darn thing only runs once.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

35reactions
haluvibecommented, Jul 7, 2016

Wrap the browserSync.reload() in a function with a done callback :


function reload(done) {
  browserSync.reload();
  done();
}

gulp.watch(['scripts/**/*.js','!scripts/main.min.js'], gulp.series(buildScripts, reload));
0reactions
joe-watkinscommented, May 6, 2016

@phated @TrySound Thanks very much for the help! 😉

Here is what I ended up doing to solve the issue w/Browsersync and Gulp 4.

Removed the reload from the watch:

gulp.watch(['scripts/**/*.js','!scripts/main.min.js'], buildScripts);

Added .pipe(browserSync.stream()) to my task:

function buildScripts(){
      return gulp.src(appDefaults.mainJsFiles)
        .pipe(concat(appDefaults.jsMin))
        .pipe(uglify())
        .pipe(gulp.dest(appDefaults.jsDir))
        .pipe(browserSync.stream()) // <!-- this is the line added
        .pipe(notify({message: 'JS Compiled'}));
    }
Read more comments on GitHub >

github_iconTop Results From Across the Web

Gulp Watch only run once - Stack Overflow
I'm changing files, but watch is only executed the first time I change a file. E.g. if I start gulp watch , change...
Read more >
New US update for Galaxy Watch 4 just bricked my watch.
Bricked after installing the GVK4 firmware. ... My g4 watch wouldn't even turn on after this update. It's now on the way back...
Read more >
Galaxy Watch 4, 5, 5 Pro: Frozen Screen, Stuck or ... - YouTube
I show you how to fix a Samsung Galaxy Watch 4 (same for Galaxy Watch 5 & 5 Pro) where the screen is...
Read more >
Got your Samsung Galaxy Watch 4: Change these settings first!!!
In this video I share with you some of the first things to do and settings to change after getting your Samsung Galaxy...
Read more >
How to Improve Battery Life on Galaxy Watch 4 and ... - YouTube
Here are 10 tips to save and improve the battery of your Samsung Galaxy Watch 4 and Galaxy Watch 4 Classic!See Samsung Galaxy...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found