mocha 10.8.0 → 10.8.1

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.
@@ -181,8 +181,24 @@ const loadPkgRc = (args = {}) => {
181
181
  result = {};
182
182
  const filepath = args.package || findUp.sync(mocharc.package);
183
183
  if (filepath) {
184
+ let configData;
184
185
  try {
185
- const pkg = JSON.parse(fs.readFileSync(filepath, 'utf8'));
186
+ configData = fs.readFileSync(filepath, 'utf8');
187
+ } catch (err) {
188
+ // If `args.package` was explicitly specified, throw an error
189
+ if (filepath == args.package) {
190
+ throw createUnparsableFileError(
191
+ `Unable to read ${filepath}: ${err}`,
192
+ filepath
193
+ );
194
+ } else {
195
+ debug('failed to read default package.json at %s; ignoring',
196
+ filepath);
197
+ return result;
198
+ }
199
+ }
200
+ try {
201
+ const pkg = JSON.parse(configData);
186
202
  if (pkg.mocha) {
187
203
  debug('`mocha` prop of package.json parsed: %O', pkg.mocha);
188
204
  result = pkg.mocha;
@@ -190,13 +206,11 @@ const loadPkgRc = (args = {}) => {
190
206
  debug('no config found in %s', filepath);
191
207
  }
192
208
  } catch (err) {
193
- if (args.package) {
194
- throw createUnparsableFileError(
195
- `Unable to read/parse ${filepath}: ${err}`,
196
- filepath
197
- );
198
- }
199
- debug('failed to read default package.json at %s; ignoring', filepath);
209
+ // If JSON failed to parse, throw an error.
210
+ throw createUnparsableFileError(
211
+ `Unable to parse ${filepath}: ${err}`,
212
+ filepath
213
+ );
200
214
  }
201
215
  }
202
216
  return result;
@@ -294,7 +294,7 @@ function makeUrl(s) {
294
294
  window.location.pathname +
295
295
  (search ? search + '&' : '?') +
296
296
  'grep=' +
297
- encodeURIComponent(escapeRe(s))
297
+ encodeURIComponent(s)
298
298
  );
299
299
  }
300
300
 
@@ -304,7 +304,7 @@ function makeUrl(s) {
304
304
  * @param {Object} [suite]
305
305
  */
306
306
  HTML.prototype.suiteURL = function (suite) {
307
- return makeUrl(suite.fullTitle());
307
+ return makeUrl('^' + escapeRe(suite.fullTitle()) + ' ');
308
308
  };
309
309
 
310
310
  /**
@@ -313,7 +313,7 @@ HTML.prototype.suiteURL = function (suite) {
313
313
  * @param {Object} [test]
314
314
  */
315
315
  HTML.prototype.testURL = function (test) {
316
- return makeUrl(test.fullTitle());
316
+ return makeUrl('^' + escapeRe(test.fullTitle()) + '$');
317
317
  };
318
318
 
319
319
  /**
package/mocha.js CHANGED
@@ -1,4 +1,4 @@
1
- // mocha@10.8.0 in javascript ES2018
1
+ // mocha@10.8.1 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) :
@@ -16990,7 +16990,7 @@
16990
16990
  window.location.pathname +
16991
16991
  (search ? search + '&' : '?') +
16992
16992
  'grep=' +
16993
- encodeURIComponent(escapeRe(s))
16993
+ encodeURIComponent(s)
16994
16994
  );
16995
16995
  }
16996
16996
 
@@ -17000,7 +17000,7 @@
17000
17000
  * @param {Object} [suite]
17001
17001
  */
17002
17002
  HTML.prototype.suiteURL = function (suite) {
17003
- return makeUrl(suite.fullTitle());
17003
+ return makeUrl('^' + escapeRe(suite.fullTitle()) + ' ');
17004
17004
  };
17005
17005
 
17006
17006
  /**
@@ -17009,7 +17009,7 @@
17009
17009
  * @param {Object} [test]
17010
17010
  */
17011
17011
  HTML.prototype.testURL = function (test) {
17012
- return makeUrl(test.fullTitle());
17012
+ return makeUrl('^' + escapeRe(test.fullTitle()) + '$');
17013
17013
  };
17014
17014
 
17015
17015
  /**
@@ -19199,7 +19199,7 @@
19199
19199
  };
19200
19200
 
19201
19201
  var name = "mocha";
19202
- var version = "10.8.0";
19202
+ var version = "10.8.1";
19203
19203
  var homepage = "https://mochajs.org/";
19204
19204
  var notifyLogo = "https://ibin.co/4QuRuGjXvl36.png";
19205
19205
  var require$$17 = {