mocha 5.0.3 → 5.0.4

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.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,11 @@
1
+ # 5.0.4 / 2018-03-07
2
+
3
+ ## :bug: Fixes
4
+
5
+ - [#3265]: Fixes regression in "watch" functionality introduced in v5.0.2 ([@outsideris])
6
+
7
+ [#3265]: https://github.com/mochajs/mocha/issues/3265
8
+
1
9
  # 5.0.3 / 2018-03-06
2
10
 
3
11
  This patch features a fix to address a potential "low severity" [ReDoS vulnerability](https://snyk.io/vuln/npm:diff:20180305) in the [diff](https://npm.im/diff) package (a dependency of Mocha).
package/lib/utils.js CHANGED
@@ -8,8 +8,15 @@ var debug = require('debug')('mocha:watch');
8
8
  var fs = require('fs');
9
9
  var glob = require('glob');
10
10
  var path = require('path');
11
+ var join = path.join;
11
12
  var he = require('he');
12
13
 
14
+ /**
15
+ * Ignored directories.
16
+ */
17
+
18
+ var ignore = ['node_modules', '.git'];
19
+
13
20
  exports.inherits = require('util').inherits;
14
21
 
15
22
  /**
@@ -54,6 +61,46 @@ exports.watch = function (files, fn) {
54
61
  });
55
62
  };
56
63
 
64
+ /**
65
+ * Ignored files.
66
+ *
67
+ * @api private
68
+ * @param {string} path
69
+ * @return {boolean}
70
+ */
71
+ function ignored (path) {
72
+ return !~ignore.indexOf(path);
73
+ }
74
+
75
+ /**
76
+ * Lookup files in the given `dir`.
77
+ *
78
+ * @api private
79
+ * @param {string} dir
80
+ * @param {string[]} [ext=['.js']]
81
+ * @param {Array} [ret=[]]
82
+ * @return {Array}
83
+ */
84
+ exports.files = function (dir, ext, ret) {
85
+ ret = ret || [];
86
+ ext = ext || ['js'];
87
+
88
+ var re = new RegExp('\\.(' + ext.join('|') + ')$');
89
+
90
+ fs.readdirSync(dir)
91
+ .filter(ignored)
92
+ .forEach(function (path) {
93
+ path = join(dir, path);
94
+ if (fs.lstatSync(path).isDirectory()) {
95
+ exports.files(path, ext, ret);
96
+ } else if (path.match(re)) {
97
+ ret.push(path);
98
+ }
99
+ });
100
+
101
+ return ret;
102
+ };
103
+
57
104
  /**
58
105
  * Compute a slug from the given `str`.
59
106
  *
package/mocha.js CHANGED
@@ -5812,8 +5812,15 @@ var debug = require('debug')('mocha:watch');
5812
5812
  var fs = require('fs');
5813
5813
  var glob = require('glob');
5814
5814
  var path = require('path');
5815
+ var join = path.join;
5815
5816
  var he = require('he');
5816
5817
 
5818
+ /**
5819
+ * Ignored directories.
5820
+ */
5821
+
5822
+ var ignore = ['node_modules', '.git'];
5823
+
5817
5824
  exports.inherits = require('util').inherits;
5818
5825
 
5819
5826
  /**
@@ -5858,6 +5865,46 @@ exports.watch = function (files, fn) {
5858
5865
  });
5859
5866
  };
5860
5867
 
5868
+ /**
5869
+ * Ignored files.
5870
+ *
5871
+ * @api private
5872
+ * @param {string} path
5873
+ * @return {boolean}
5874
+ */
5875
+ function ignored (path) {
5876
+ return !~ignore.indexOf(path);
5877
+ }
5878
+
5879
+ /**
5880
+ * Lookup files in the given `dir`.
5881
+ *
5882
+ * @api private
5883
+ * @param {string} dir
5884
+ * @param {string[]} [ext=['.js']]
5885
+ * @param {Array} [ret=[]]
5886
+ * @return {Array}
5887
+ */
5888
+ exports.files = function (dir, ext, ret) {
5889
+ ret = ret || [];
5890
+ ext = ext || ['js'];
5891
+
5892
+ var re = new RegExp('\\.(' + ext.join('|') + ')$');
5893
+
5894
+ fs.readdirSync(dir)
5895
+ .filter(ignored)
5896
+ .forEach(function (path) {
5897
+ path = join(dir, path);
5898
+ if (fs.lstatSync(path).isDirectory()) {
5899
+ exports.files(path, ext, ret);
5900
+ } else if (path.match(re)) {
5901
+ ret.push(path);
5902
+ }
5903
+ });
5904
+
5905
+ return ret;
5906
+ };
5907
+
5861
5908
  /**
5862
5909
  * Compute a slug from the given `str`.
5863
5910
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mocha",
3
- "version": "5.0.3",
3
+ "version": "5.0.4",
4
4
  "description": "simple, flexible, fun test framework",
5
5
  "keywords": [
6
6
  "mocha",