mocha 5.0.1 → 5.0.5
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 +109 -12
- package/README.md +25 -41
- package/lib/interfaces/common.js +2 -0
- package/lib/reporters/base.js +33 -18
- package/lib/reporters/dot.js +1 -1
- package/lib/reporters/json-stream.js +1 -1
- package/lib/reporters/json.js +1 -1
- package/lib/reporters/landing.js +1 -1
- package/lib/reporters/list.js +1 -1
- package/lib/reporters/markdown.js +1 -1
- package/lib/reporters/min.js +1 -1
- package/lib/reporters/nyan.js +1 -1
- package/lib/reporters/progress.js +1 -1
- package/lib/reporters/spec.js +1 -1
- package/lib/reporters/tap.js +1 -1
- package/lib/reporters/xunit.js +1 -1
- package/lib/runnable.js +19 -1
- package/lib/runner.js +16 -12
- package/lib/utils.js +18 -25
- package/mocha.js +192 -119
- package/package.json +3 -3
- package/CHANGELOG.md.orig +0 -1736
- package/README.md.orig +0 -132
package/lib/utils.js
CHANGED
|
@@ -1,21 +1,14 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
/* eslint-env browser */
|
|
4
|
-
|
|
5
3
|
/**
|
|
6
4
|
* Module dependencies.
|
|
7
5
|
*/
|
|
8
6
|
|
|
9
|
-
var basename = require('path').basename;
|
|
10
7
|
var debug = require('debug')('mocha:watch');
|
|
11
|
-
var
|
|
8
|
+
var fs = require('fs');
|
|
12
9
|
var glob = require('glob');
|
|
13
10
|
var path = require('path');
|
|
14
11
|
var join = path.join;
|
|
15
|
-
var readdirSync = require('fs').readdirSync;
|
|
16
|
-
var statSync = require('fs').statSync;
|
|
17
|
-
var watchFile = require('fs').watchFile;
|
|
18
|
-
var lstatSync = require('fs').lstatSync;
|
|
19
12
|
var he = require('he');
|
|
20
13
|
|
|
21
14
|
/**
|
|
@@ -60,7 +53,7 @@ exports.watch = function (files, fn) {
|
|
|
60
53
|
var options = { interval: 100 };
|
|
61
54
|
files.forEach(function (file) {
|
|
62
55
|
debug('file %s', file);
|
|
63
|
-
watchFile(file, options, function (curr, prev) {
|
|
56
|
+
fs.watchFile(file, options, function (curr, prev) {
|
|
64
57
|
if (prev.mtime < curr.mtime) {
|
|
65
58
|
fn(file);
|
|
66
59
|
}
|
|
@@ -94,11 +87,11 @@ exports.files = function (dir, ext, ret) {
|
|
|
94
87
|
|
|
95
88
|
var re = new RegExp('\\.(' + ext.join('|') + ')$');
|
|
96
89
|
|
|
97
|
-
readdirSync(dir)
|
|
90
|
+
fs.readdirSync(dir)
|
|
98
91
|
.filter(ignored)
|
|
99
92
|
.forEach(function (path) {
|
|
100
93
|
path = join(dir, path);
|
|
101
|
-
if (lstatSync(path).isDirectory()) {
|
|
94
|
+
if (fs.lstatSync(path).isDirectory()) {
|
|
102
95
|
exports.files(path, ext, ret);
|
|
103
96
|
} else if (path.match(re)) {
|
|
104
97
|
ret.push(path);
|
|
@@ -469,40 +462,40 @@ exports.canonicalize = function canonicalize (value, stack, typeHint) {
|
|
|
469
462
|
* Lookup file names at the given `path`.
|
|
470
463
|
*
|
|
471
464
|
* @api public
|
|
472
|
-
* @param {string}
|
|
465
|
+
* @param {string} filepath Base path to start searching from.
|
|
473
466
|
* @param {string[]} extensions File extensions to look for.
|
|
474
467
|
* @param {boolean} recursive Whether or not to recurse into subdirectories.
|
|
475
468
|
* @return {string[]} An array of paths.
|
|
476
469
|
*/
|
|
477
|
-
exports.lookupFiles = function lookupFiles (
|
|
470
|
+
exports.lookupFiles = function lookupFiles (filepath, extensions, recursive) {
|
|
478
471
|
var files = [];
|
|
479
472
|
|
|
480
|
-
if (!
|
|
481
|
-
if (
|
|
482
|
-
|
|
473
|
+
if (!fs.existsSync(filepath)) {
|
|
474
|
+
if (fs.existsSync(filepath + '.js')) {
|
|
475
|
+
filepath += '.js';
|
|
483
476
|
} else {
|
|
484
|
-
files = glob.sync(
|
|
477
|
+
files = glob.sync(filepath);
|
|
485
478
|
if (!files.length) {
|
|
486
|
-
throw new Error("cannot resolve path (or pattern) '" +
|
|
479
|
+
throw new Error("cannot resolve path (or pattern) '" + filepath + "'");
|
|
487
480
|
}
|
|
488
481
|
return files;
|
|
489
482
|
}
|
|
490
483
|
}
|
|
491
484
|
|
|
492
485
|
try {
|
|
493
|
-
var stat = statSync(
|
|
486
|
+
var stat = fs.statSync(filepath);
|
|
494
487
|
if (stat.isFile()) {
|
|
495
|
-
return
|
|
488
|
+
return filepath;
|
|
496
489
|
}
|
|
497
490
|
} catch (err) {
|
|
498
491
|
// ignore error
|
|
499
492
|
return;
|
|
500
493
|
}
|
|
501
494
|
|
|
502
|
-
readdirSync(
|
|
503
|
-
file = join(
|
|
495
|
+
fs.readdirSync(filepath).forEach(function (file) {
|
|
496
|
+
file = path.join(filepath, file);
|
|
504
497
|
try {
|
|
505
|
-
var stat = statSync(file);
|
|
498
|
+
var stat = fs.statSync(file);
|
|
506
499
|
if (stat.isDirectory()) {
|
|
507
500
|
if (recursive) {
|
|
508
501
|
files = files.concat(lookupFiles(file, extensions, recursive));
|
|
@@ -514,7 +507,7 @@ exports.lookupFiles = function lookupFiles (path, extensions, recursive) {
|
|
|
514
507
|
return;
|
|
515
508
|
}
|
|
516
509
|
var re = new RegExp('\\.(?:' + extensions.join('|') + ')$');
|
|
517
|
-
if (!stat.isFile() || !re.test(file) || basename(file)[0] === '.') {
|
|
510
|
+
if (!stat.isFile() || !re.test(file) || path.basename(file)[0] === '.') {
|
|
518
511
|
return;
|
|
519
512
|
}
|
|
520
513
|
files.push(file);
|
|
@@ -597,7 +590,7 @@ exports.stackTraceFilter = function () {
|
|
|
597
590
|
|
|
598
591
|
// Clean up cwd(absolute)
|
|
599
592
|
if (/\(?.+:\d+:\d+\)?$/.test(line)) {
|
|
600
|
-
line = line.replace(cwd, '');
|
|
593
|
+
line = line.replace('(' + cwd, '(');
|
|
601
594
|
}
|
|
602
595
|
|
|
603
596
|
list.push(line);
|