Skip to content

Commit

Permalink
Don't throttle or debounce if those options were not specified.
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 open-cli-tools#71.
  • Loading branch information
sbleon committed Nov 4, 2019
1 parent 42a6ea8 commit c8400d6
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
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 c8400d6

Please sign in to comment.