From fab6cc569189fc5d3be6f05b3a44383427e998a7 Mon Sep 17 00:00:00 2001 From: bmar Date: Sat, 5 Sep 2015 09:23:42 -0700 Subject: [PATCH] prevent race conditions in bsReload between wiredep, less, and js, was getting race conditions because 'serve-build' was kicking off optimize indiscriminately. Added 'syncing' flag to prevent optimize from getting called recursively. --- gulpfile.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/gulpfile.js b/gulpfile.js index e2afca37..b476839a 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -11,6 +11,7 @@ var $ = require('gulp-load-plugins')({lazy: true}); var colors = $.util.colors; var envenv = $.util.env; var port = process.env.PORT || config.defaultPort; +var syncing = false; /** * yargs variables can be passed in to alter the behavior, when present. @@ -370,7 +371,16 @@ gulp.task('bump', function() { /** * Optimize the code and re-load browserSync */ -gulp.task('browserSyncReload', ['optimize'], browserSync.reload); +gulp.task('browserSyncReload', function() { + if (syncing) { + return; + } + syncing = true; + gulp.start('optimize', function() { + browserSync.reload(); + syncing = false; + }); +}); ////////////////