Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Invalidate cache for watched files #271

Closed
wants to merge 6 commits into from
This page is out of date. Refresh to see the latest.
Showing with 12 additions and 2 deletions.
  1. +12 −2 bin/_mocha
View
14 bin/_mocha
@@ -209,8 +209,17 @@ if (program.watch) {
play(frames);
- utils.watch(utils.files(cwd), function(){
- stop()
+ watchFiles = utils.files(cwd);
+
+ // Invalidate require() cache for watched files
+ function invalidate() {
+ watchFiles.forEach(function(file) {
+ delete require.cache[file];
+ });
+ }
+ utils.watch(watchFiles, function() {
+ invalidate();
+ stop();
suite = suite.clone();
ui = interfaces[program.ui](suite);
load(files, function(){
@@ -317,6 +326,7 @@ function play(arr, interval) {
, interval = interval || 100
, i = 0;
+ clearInterval(play.timer);
play.timer = setInterval(function(){
var str = arr[i++ % len];
process.stdout.write('\r' + str);
Something went wrong with that request. Please try again.