mocha 11.2.1 → 11.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -6,6 +6,7 @@ const path = require('node:path');
6
6
  const chokidar = require('chokidar');
7
7
  const Context = require('../context');
8
8
  const collectFiles = require('./collect-files');
9
+ const glob = require('glob');
9
10
 
10
11
  /**
11
12
  * Exports the `watchRun` function that runs mocha in "watch" mode.
@@ -136,6 +137,42 @@ exports.watchRun = (mocha, {watchFiles, watchIgnore}, fileCollectParams) => {
136
137
  });
137
138
  };
138
139
 
140
+ class GlobFilesTracker {
141
+ constructor(watchFiles, watchIgnore) {
142
+ this.watchFilesSet = new Set();
143
+ this.watchFiles = watchFiles;
144
+ this.watchIgnore = watchIgnore;
145
+ }
146
+
147
+ regenerate() {
148
+ const watchIgnoreSet = new Set();
149
+ for (const pattern of this.watchIgnore) {
150
+ glob.sync(pattern, { dot: true }).forEach(filePath => watchIgnoreSet.add(filePath));
151
+ }
152
+
153
+ const globOpts = {
154
+ dot: true,
155
+ ignore: {
156
+ childrenIgnored: pathToCheck => watchIgnoreSet.has(pathToCheck.relative())
157
+ }
158
+ };
159
+
160
+ this.watchFilesSet.clear();
161
+ for (const pattern of this.watchFiles) {
162
+ glob.sync(pattern, globOpts).forEach(pathToCheck => {
163
+ if (watchIgnoreSet.has(pathToCheck)) {
164
+ return;
165
+ }
166
+ this.watchFilesSet.add(pathToCheck);
167
+ });
168
+ }
169
+ }
170
+
171
+ has(filePath) {
172
+ return this.watchFilesSet.has(filePath)
173
+ }
174
+ }
175
+
139
176
  /**
140
177
  * Bootstraps a chokidar watcher. Handles keyboard input & signals
141
178
  * @param {Mocha} mocha - Mocha instance
@@ -167,8 +204,10 @@ const createWatcher = (
167
204
  // we handle global fixtures manually
168
205
  mocha.enableGlobalSetup(false).enableGlobalTeardown(false);
169
206
 
170
- const watcher = chokidar.watch(watchFiles, {
171
- ignored: watchIgnore,
207
+ const tracker = new GlobFilesTracker(watchFiles, watchIgnore);
208
+ tracker.regenerate();
209
+
210
+ const watcher = chokidar.watch('.', {
172
211
  ignoreInitial: true
173
212
  });
174
213
 
@@ -184,8 +223,13 @@ const createWatcher = (
184
223
  rerunner.run();
185
224
  });
186
225
 
187
- watcher.on('all', () => {
188
- rerunner.scheduleRun();
226
+ watcher.on('all', (event, filePath) => {
227
+ if (event === 'add') {
228
+ tracker.regenerate();
229
+ }
230
+ if (tracker.has(filePath)) {
231
+ rerunner.scheduleRun();
232
+ }
189
233
  });
190
234
 
191
235
  hideCursor();
package/mocha.js CHANGED
@@ -1,4 +1,4 @@
1
- // mocha@11.2.1 in javascript ES2018
1
+ // mocha@11.2.2 in javascript ES2018
2
2
  (function (global, factory) {
3
3
  typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
4
4
  typeof define === 'function' && define.amd ? define(factory) :
@@ -19256,7 +19256,7 @@
19256
19256
  };
19257
19257
 
19258
19258
  var name = "mocha";
19259
- var version = "11.2.1";
19259
+ var version = "11.2.2";
19260
19260
  var homepage = "https://mochajs.org/";
19261
19261
  var notifyLogo = "https://ibin.co/4QuRuGjXvl36.png";
19262
19262
  var require$$17 = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mocha",
3
- "version": "11.2.1",
3
+ "version": "11.2.2",
4
4
  "type": "commonjs",
5
5
  "description": "simple, flexible, fun test framework",
6
6
  "keywords": [
@@ -95,7 +95,7 @@
95
95
  },
96
96
  "dependencies": {
97
97
  "browser-stdout": "^1.3.1",
98
- "chokidar": "^3.5.3",
98
+ "chokidar": "^4.0.1",
99
99
  "debug": "^4.3.5",
100
100
  "diff": "^5.2.0",
101
101
  "escape-string-regexp": "^4.0.0",