-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replaced gulp.watch with latest chokidar which is more reliable
- Loading branch information
Showing
11 changed files
with
247 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
const gulp = require('gulp'); | ||
const chokidar = require('chokidar'); | ||
const debounce = require('just-debounce'); | ||
const asyncDone = require('async-done'); | ||
|
||
|
||
/** | ||
* Gulp task watch function using latest chokidar | ||
* with better OSX support and file watching functionality | ||
* than outdated gulp.watch | ||
*/ | ||
module.exports = function taskWatch (globs, callback) { | ||
const parallelCallback = gulp.parallel(callback); | ||
const debouncedCallback = debounce(onChange, 200); | ||
let running = false; | ||
let queued = false; | ||
|
||
function onChange () { | ||
if (running) { | ||
queued = true; | ||
} else { | ||
running = true; | ||
asyncDone(parallelCallback, runComplete); | ||
} | ||
} | ||
function runComplete (err) { | ||
running = false; | ||
|
||
// If we have a run queued, start onChange again | ||
if (queued) { | ||
queued = false; | ||
onChange(); | ||
} | ||
} | ||
|
||
return chokidar.watch(globs, { | ||
ignoreInitial: true | ||
}) | ||
.on('add', debouncedCallback) | ||
.on('change', debouncedCallback) | ||
.on('unlink', debouncedCallback); | ||
}; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.