☕️ Classic, reliable, trusted test framework for Node.js and the browser
Abort previous run on --watch change.
Benjie Gillam7d7cf6730056
diff --git a/bin/_mocha b/bin/_mochaindex bf5fa058..c60e86d3 100644--- a/bin/_mocha+++ b/bin/_mocha@@ -296,6 +296,7 @@ if (program.sort) {// --watch+var runner;if (program.watch) {console.log();hideCursor();@@ -310,7 +311,7 @@ if (program.watch) {function loadAndRun() {try {mocha.files = files;- mocha.run(function(){});+ runner = mocha.run(function(){});} catch(e) {console.log(e.stack);}@@ -327,6 +328,9 @@ if (program.watch) {utils.watch(watchFiles, function(){purge();stop()+ if (runner) {+ runner.abort();+ }mocha.suite = mocha.suite.clone();mocha.ui(program.ui);loadAndRun();@@ -338,7 +342,7 @@ if (program.watch) {// loadmocha.files = files;-var runner = mocha.run(program.exit ? process.exit : exitLater);+runner = mocha.run(program.exit ? process.exit : exitLater);function exitLater(code) {process.on('exit', function() { process.exit(code) })