From a15cf5e3e494b6c07912bd053f62976299b25a22 Mon Sep 17 00:00:00 2001 From: Stephen Hallett Date: Mon, 5 Mar 2018 14:46:35 +1100 Subject: [PATCH] Added check for debounce necessity to avoid altogether --- index.js | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/index.js b/index.js index e638668..73c0888 100755 --- a/index.js +++ b/index.js @@ -154,11 +154,19 @@ function startWatching(opts) { // XXX: commands might be still run concurrently if (opts.command) { - debouncedRun( - opts.command - .replace(/\{path\}/ig, path) - .replace(/\{event\}/ig, event) - ); + if (opts.debounce > 0) { + debouncedRun( + opts.command + .replace(/\{path\}/ig, path) + .replace(/\{event\}/ig, event) + ); + } else { + throttledRun( + opts.command + .replace(/\{path\}/ig, path) + .replace(/\{event\}/ig, event) + ); + } } });