Skip to content

Commit

Permalink
Don't throttle or debounce if those options were not specified. (#90)
Browse files Browse the repository at this point in the history
This allows the custom command to be run once for each path modified in a
single event, and resolves #71.
  • Loading branch information
sbleon authored and paulmillr committed Nov 5, 2019
1 parent 99e4b47 commit 331243f
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions index.js
Expand Up @@ -140,8 +140,16 @@ function startWatching(opts) {
const chokidarOpts = createChokidarOpts(opts);
const watcher = chokidar.watch(opts.patterns, chokidarOpts);

const throttledRun = throttle(run, opts.throttle);
const debouncedRun = debounce(throttledRun, opts.debounce);
let throttledRun = run;
if (opts.throttle > 0) {
throttledRun = throttle(run, opts.throttle);
}

let debouncedRun = throttledRun;
if (opts.debounce > 0) {
debouncedRun = debounce(throttledRun, opts.debounce);
}

watcher.on('all', (event, path) => {
const description = `${EVENT_DESCRIPTIONS[event]}:`;

Expand Down

0 comments on commit 331243f

Please sign in to comment.