mocha-compat 10.8.2 → 10.8.3

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mocha-compat",
3
- "version": "10.8.2",
3
+ "version": "10.8.3",
4
4
  "type": "commonjs",
5
5
  "description": "Fork of mocha 10.8.2 with serialize-javascript vendored so npm audit is clean on Node 12.17 through 26. Install as an alias next to mocha: \"mocha-compat-10\": \"npm:mocha-compat@^10\"",
6
6
  "keywords": [
@@ -57,7 +57,7 @@
57
57
  "lint:markdown": "markdownlint \"*.md\" \"docs/**/*.md\" \".github/*.md\" \"lib/**/*.md\" \"test/**/*.md\" \"example/**/*.md\" -i CHANGELOG.md",
58
58
  "lint": "run-p lint:*",
59
59
  "prepack": "run-s clean build",
60
- "prepublishOnly": "run-s clean build",
60
+ "prepublishOnly": "node scripts/require-support-branch.js && run-s clean build",
61
61
  "test-browser-run": "cross-env NODE_PATH=. karma start ./karma.conf.js --single-run",
62
62
  "test-browser:reporters:bdd": "cross-env MOCHA_TEST=bdd npm run -s test-browser-run",
63
63
  "test-browser:reporters:esm": "cross-env MOCHA_TEST=esm npm run -s test-browser-run",
@@ -100,16 +100,19 @@
100
100
  "diff": "^5.2.2",
101
101
  "escape-string-regexp": "^4.0.0",
102
102
  "find-up": "^5.0.0",
103
- "glob": "^8.1.0",
103
+ "fs.realpath": "^1.0.0",
104
104
  "he": "^1.2.0",
105
+ "inherits": "2",
105
106
  "js-yaml": "^4.3.1",
106
107
  "log-symbols": "^4.1.0",
107
108
  "minimatch": "^5.1.8",
108
109
  "ms": "^2.1.3",
110
+ "once": "^1.4.0",
109
111
  "randombytes": "^2.1.0",
110
112
  "strip-json-comments": "^3.1.1",
111
113
  "supports-color": "^8.1.1",
112
114
  "workerpool": "^6.5.1",
115
+ "wrappy": "^1.0.2",
113
116
  "yargs": "^16.2.0",
114
117
  "yargs-parser": "^20.2.9",
115
118
  "yargs-unparser": "^2.0.0"
@@ -129,6 +132,7 @@
129
132
  "eslint": "^8.56.0",
130
133
  "fail-on-errors-webpack-plugin": "^3.0.0",
131
134
  "fs-extra": "^10.0.0",
135
+ "glob": "^8.1.0",
132
136
  "globals": "^13.24.0",
133
137
  "jsdoc": "^3.6.7",
134
138
  "jsdoc-ts-utils": "^2.0.1",
@@ -0,0 +1,15 @@
1
+ The ISC License
2
+
3
+ Copyright (c) 2009-2022 Isaac Z. Schlueter and Contributors
4
+
5
+ Permission to use, copy, modify, and/or distribute this software for any
6
+ purpose with or without fee is hereby granted, provided that the above
7
+ copyright notice and this permission notice appear in all copies.
8
+
9
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10
+ WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11
+ MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12
+ ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13
+ WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14
+ ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
15
+ IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
@@ -0,0 +1,11 @@
1
+ # vendored glob
2
+
3
+ glob 8.1.0, byte-identical to the published tarball except that `require('inflight')` in `glob.js`
4
+ points at `../inflight/inflight.js`.
5
+
6
+ Upstream deprecated glob 8 as unsupported, and it pulls `inflight`, which is deprecated for leaking
7
+ memory. Neither has a fix on this line: glob 9 removed the sync and callback API that
8
+ `lib/cli/lookup-files.js` uses, and mocha only escaped glob in 11. Vendoring both is what keeps the
9
+ production tree free of deprecated packages, the same way `support/3.x` does it.
10
+
11
+ Regenerate with `npm pack glob@8.1.0` and re-apply the one inflight line rather than editing in place.
@@ -0,0 +1,244 @@
1
+ exports.setopts = setopts
2
+ exports.ownProp = ownProp
3
+ exports.makeAbs = makeAbs
4
+ exports.finish = finish
5
+ exports.mark = mark
6
+ exports.isIgnored = isIgnored
7
+ exports.childrenIgnored = childrenIgnored
8
+
9
+ function ownProp (obj, field) {
10
+ return Object.prototype.hasOwnProperty.call(obj, field)
11
+ }
12
+
13
+ var fs = require("fs")
14
+ var path = require("path")
15
+ var minimatch = require("minimatch")
16
+ var isAbsolute = require("path").isAbsolute
17
+ var Minimatch = minimatch.Minimatch
18
+
19
+ function alphasort (a, b) {
20
+ return a.localeCompare(b, 'en')
21
+ }
22
+
23
+ function setupIgnores (self, options) {
24
+ self.ignore = options.ignore || []
25
+
26
+ if (!Array.isArray(self.ignore))
27
+ self.ignore = [self.ignore]
28
+
29
+ if (self.ignore.length) {
30
+ self.ignore = self.ignore.map(ignoreMap)
31
+ }
32
+ }
33
+
34
+ // ignore patterns are always in dot:true mode.
35
+ function ignoreMap (pattern) {
36
+ var gmatcher = null
37
+ if (pattern.slice(-3) === '/**') {
38
+ var gpattern = pattern.replace(/(\/\*\*)+$/, '')
39
+ gmatcher = new Minimatch(gpattern, { dot: true })
40
+ }
41
+
42
+ return {
43
+ matcher: new Minimatch(pattern, { dot: true }),
44
+ gmatcher: gmatcher
45
+ }
46
+ }
47
+
48
+ function setopts (self, pattern, options) {
49
+ if (!options)
50
+ options = {}
51
+
52
+ // base-matching: just use globstar for that.
53
+ if (options.matchBase && -1 === pattern.indexOf("/")) {
54
+ if (options.noglobstar) {
55
+ throw new Error("base matching requires globstar")
56
+ }
57
+ pattern = "**/" + pattern
58
+ }
59
+
60
+ self.windowsPathsNoEscape = !!options.windowsPathsNoEscape ||
61
+ options.allowWindowsEscape === false
62
+ if (self.windowsPathsNoEscape) {
63
+ pattern = pattern.replace(/\\/g, '/')
64
+ }
65
+
66
+ self.silent = !!options.silent
67
+ self.pattern = pattern
68
+ self.strict = options.strict !== false
69
+ self.realpath = !!options.realpath
70
+ self.realpathCache = options.realpathCache || Object.create(null)
71
+ self.follow = !!options.follow
72
+ self.dot = !!options.dot
73
+ self.mark = !!options.mark
74
+ self.nodir = !!options.nodir
75
+ if (self.nodir)
76
+ self.mark = true
77
+ self.sync = !!options.sync
78
+ self.nounique = !!options.nounique
79
+ self.nonull = !!options.nonull
80
+ self.nosort = !!options.nosort
81
+ self.nocase = !!options.nocase
82
+ self.stat = !!options.stat
83
+ self.noprocess = !!options.noprocess
84
+ self.absolute = !!options.absolute
85
+ self.fs = options.fs || fs
86
+
87
+ self.maxLength = options.maxLength || Infinity
88
+ self.cache = options.cache || Object.create(null)
89
+ self.statCache = options.statCache || Object.create(null)
90
+ self.symlinks = options.symlinks || Object.create(null)
91
+
92
+ setupIgnores(self, options)
93
+
94
+ self.changedCwd = false
95
+ var cwd = process.cwd()
96
+ if (!ownProp(options, "cwd"))
97
+ self.cwd = path.resolve(cwd)
98
+ else {
99
+ self.cwd = path.resolve(options.cwd)
100
+ self.changedCwd = self.cwd !== cwd
101
+ }
102
+
103
+ self.root = options.root || path.resolve(self.cwd, "/")
104
+ self.root = path.resolve(self.root)
105
+
106
+ // TODO: is an absolute `cwd` supposed to be resolved against `root`?
107
+ // e.g. { cwd: '/test', root: __dirname } === path.join(__dirname, '/test')
108
+ self.cwdAbs = isAbsolute(self.cwd) ? self.cwd : makeAbs(self, self.cwd)
109
+ self.nomount = !!options.nomount
110
+
111
+ if (process.platform === "win32") {
112
+ self.root = self.root.replace(/\\/g, "/")
113
+ self.cwd = self.cwd.replace(/\\/g, "/")
114
+ self.cwdAbs = self.cwdAbs.replace(/\\/g, "/")
115
+ }
116
+
117
+ // disable comments and negation in Minimatch.
118
+ // Note that they are not supported in Glob itself anyway.
119
+ options.nonegate = true
120
+ options.nocomment = true
121
+
122
+ self.minimatch = new Minimatch(pattern, options)
123
+ self.options = self.minimatch.options
124
+ }
125
+
126
+ function finish (self) {
127
+ var nou = self.nounique
128
+ var all = nou ? [] : Object.create(null)
129
+
130
+ for (var i = 0, l = self.matches.length; i < l; i ++) {
131
+ var matches = self.matches[i]
132
+ if (!matches || Object.keys(matches).length === 0) {
133
+ if (self.nonull) {
134
+ // do like the shell, and spit out the literal glob
135
+ var literal = self.minimatch.globSet[i]
136
+ if (nou)
137
+ all.push(literal)
138
+ else
139
+ all[literal] = true
140
+ }
141
+ } else {
142
+ // had matches
143
+ var m = Object.keys(matches)
144
+ if (nou)
145
+ all.push.apply(all, m)
146
+ else
147
+ m.forEach(function (m) {
148
+ all[m] = true
149
+ })
150
+ }
151
+ }
152
+
153
+ if (!nou)
154
+ all = Object.keys(all)
155
+
156
+ if (!self.nosort)
157
+ all = all.sort(alphasort)
158
+
159
+ // at *some* point we statted all of these
160
+ if (self.mark) {
161
+ for (var i = 0; i < all.length; i++) {
162
+ all[i] = self._mark(all[i])
163
+ }
164
+ if (self.nodir) {
165
+ all = all.filter(function (e) {
166
+ var notDir = !(/\/$/.test(e))
167
+ var c = self.cache[e] || self.cache[makeAbs(self, e)]
168
+ if (notDir && c)
169
+ notDir = c !== 'DIR' && !Array.isArray(c)
170
+ return notDir
171
+ })
172
+ }
173
+ }
174
+
175
+ if (self.ignore.length)
176
+ all = all.filter(function(m) {
177
+ return !isIgnored(self, m)
178
+ })
179
+
180
+ self.found = all
181
+ }
182
+
183
+ function mark (self, p) {
184
+ var abs = makeAbs(self, p)
185
+ var c = self.cache[abs]
186
+ var m = p
187
+ if (c) {
188
+ var isDir = c === 'DIR' || Array.isArray(c)
189
+ var slash = p.slice(-1) === '/'
190
+
191
+ if (isDir && !slash)
192
+ m += '/'
193
+ else if (!isDir && slash)
194
+ m = m.slice(0, -1)
195
+
196
+ if (m !== p) {
197
+ var mabs = makeAbs(self, m)
198
+ self.statCache[mabs] = self.statCache[abs]
199
+ self.cache[mabs] = self.cache[abs]
200
+ }
201
+ }
202
+
203
+ return m
204
+ }
205
+
206
+ // lotta situps...
207
+ function makeAbs (self, f) {
208
+ var abs = f
209
+ if (f.charAt(0) === '/') {
210
+ abs = path.join(self.root, f)
211
+ } else if (isAbsolute(f) || f === '') {
212
+ abs = f
213
+ } else if (self.changedCwd) {
214
+ abs = path.resolve(self.cwd, f)
215
+ } else {
216
+ abs = path.resolve(f)
217
+ }
218
+
219
+ if (process.platform === 'win32')
220
+ abs = abs.replace(/\\/g, '/')
221
+
222
+ return abs
223
+ }
224
+
225
+
226
+ // Return true, if pattern ends with globstar '**', for the accompanying parent directory.
227
+ // Ex:- If node_modules/** is the pattern, add 'node_modules' to ignore list along with it's contents
228
+ function isIgnored (self, path) {
229
+ if (!self.ignore.length)
230
+ return false
231
+
232
+ return self.ignore.some(function(item) {
233
+ return item.matcher.match(path) || !!(item.gmatcher && item.gmatcher.match(path))
234
+ })
235
+ }
236
+
237
+ function childrenIgnored (self, path) {
238
+ if (!self.ignore.length)
239
+ return false
240
+
241
+ return self.ignore.some(function(item) {
242
+ return !!(item.gmatcher && item.gmatcher.match(path))
243
+ })
244
+ }