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/mocha.js
CHANGED
|
@@ -718,6 +718,8 @@ module.exports = function (suites, context, mocha) {
|
|
|
718
718
|
suites.shift();
|
|
719
719
|
} else if (typeof opts.fn === 'undefined' && !suite.pending) {
|
|
720
720
|
throw new Error('Suite "' + suite.fullTitle() + '" was defined but no callback was supplied. Supply a callback or explicitly skip the suite.');
|
|
721
|
+
} else if (!opts.fn && suite.pending) {
|
|
722
|
+
suites.shift();
|
|
721
723
|
}
|
|
722
724
|
|
|
723
725
|
return suite;
|
|
@@ -1898,6 +1900,22 @@ function stringifyDiffObjs (err) {
|
|
|
1898
1900
|
}
|
|
1899
1901
|
}
|
|
1900
1902
|
|
|
1903
|
+
/**
|
|
1904
|
+
* Returns a diff between 2 strings with coloured ANSI output.
|
|
1905
|
+
*
|
|
1906
|
+
* The diff will be either inline or unified dependant on the value
|
|
1907
|
+
* of `Base.inlineDiff`.
|
|
1908
|
+
*
|
|
1909
|
+
* @param {string} actual
|
|
1910
|
+
* @param {string} expected
|
|
1911
|
+
* @return {string} Diff
|
|
1912
|
+
*/
|
|
1913
|
+
var generateDiff = exports.generateDiff = function (actual, expected) {
|
|
1914
|
+
return exports.inlineDiffs
|
|
1915
|
+
? inlineDiff(actual, expected)
|
|
1916
|
+
: unifiedDiff(actual, expected);
|
|
1917
|
+
};
|
|
1918
|
+
|
|
1901
1919
|
/**
|
|
1902
1920
|
* Output the given `failures` as a list.
|
|
1903
1921
|
*
|
|
@@ -1947,11 +1965,7 @@ exports.list = function (failures) {
|
|
|
1947
1965
|
var match = message.match(/^([^:]+): expected/);
|
|
1948
1966
|
msg = '\n ' + color('error message', match ? match[1] : msg);
|
|
1949
1967
|
|
|
1950
|
-
|
|
1951
|
-
msg += inlineDiff(err);
|
|
1952
|
-
} else {
|
|
1953
|
-
msg += unifiedDiff(err);
|
|
1954
|
-
}
|
|
1968
|
+
msg += generateDiff(err.actual, err.expected);
|
|
1955
1969
|
}
|
|
1956
1970
|
|
|
1957
1971
|
// indent stack trace
|
|
@@ -2034,7 +2048,7 @@ function Base (runner) {
|
|
|
2034
2048
|
failures.push(test);
|
|
2035
2049
|
});
|
|
2036
2050
|
|
|
2037
|
-
runner.
|
|
2051
|
+
runner.once('end', function () {
|
|
2038
2052
|
stats.end = new Date();
|
|
2039
2053
|
stats.duration = stats.end - stats.start;
|
|
2040
2054
|
});
|
|
@@ -2100,14 +2114,15 @@ function pad (str, len) {
|
|
|
2100
2114
|
}
|
|
2101
2115
|
|
|
2102
2116
|
/**
|
|
2103
|
-
* Returns an inline diff between 2 strings with coloured ANSI output
|
|
2117
|
+
* Returns an inline diff between 2 strings with coloured ANSI output.
|
|
2104
2118
|
*
|
|
2105
2119
|
* @api private
|
|
2106
|
-
* @param {
|
|
2120
|
+
* @param {String} actual
|
|
2121
|
+
* @param {String} expected
|
|
2107
2122
|
* @return {string} Diff
|
|
2108
2123
|
*/
|
|
2109
|
-
function inlineDiff (
|
|
2110
|
-
var msg = errorDiff(
|
|
2124
|
+
function inlineDiff (actual, expected) {
|
|
2125
|
+
var msg = errorDiff(actual, expected);
|
|
2111
2126
|
|
|
2112
2127
|
// linenos
|
|
2113
2128
|
var lines = msg.split('\n');
|
|
@@ -2133,13 +2148,14 @@ function inlineDiff (err) {
|
|
|
2133
2148
|
}
|
|
2134
2149
|
|
|
2135
2150
|
/**
|
|
2136
|
-
* Returns a unified diff between two strings.
|
|
2151
|
+
* Returns a unified diff between two strings with coloured ANSI output.
|
|
2137
2152
|
*
|
|
2138
2153
|
* @api private
|
|
2139
|
-
* @param {
|
|
2154
|
+
* @param {String} actual
|
|
2155
|
+
* @param {String} expected
|
|
2140
2156
|
* @return {string} The diff.
|
|
2141
2157
|
*/
|
|
2142
|
-
function unifiedDiff (
|
|
2158
|
+
function unifiedDiff (actual, expected) {
|
|
2143
2159
|
var indent = ' ';
|
|
2144
2160
|
function cleanUp (line) {
|
|
2145
2161
|
if (line[0] === '+') {
|
|
@@ -2159,7 +2175,7 @@ function unifiedDiff (err) {
|
|
|
2159
2175
|
function notBlank (line) {
|
|
2160
2176
|
return typeof line !== 'undefined' && line !== null;
|
|
2161
2177
|
}
|
|
2162
|
-
var msg = diff.createPatch('string',
|
|
2178
|
+
var msg = diff.createPatch('string', actual, expected);
|
|
2163
2179
|
var lines = msg.split('\n').splice(5);
|
|
2164
2180
|
return '\n ' +
|
|
2165
2181
|
colorLines('diff added', '+ expected') + ' ' +
|
|
@@ -2172,11 +2188,12 @@ function unifiedDiff (err) {
|
|
|
2172
2188
|
* Return a character diff for `err`.
|
|
2173
2189
|
*
|
|
2174
2190
|
* @api private
|
|
2175
|
-
* @param {
|
|
2176
|
-
* @
|
|
2191
|
+
* @param {String} actual
|
|
2192
|
+
* @param {String} expected
|
|
2193
|
+
* @return {string} the diff
|
|
2177
2194
|
*/
|
|
2178
|
-
function errorDiff (
|
|
2179
|
-
return diff.diffWordsWithSpace(
|
|
2195
|
+
function errorDiff (actual, expected) {
|
|
2196
|
+
return diff.diffWordsWithSpace(actual, expected).map(function (str) {
|
|
2180
2197
|
if (str.added) {
|
|
2181
2198
|
return colorLines('diff added', str.value);
|
|
2182
2199
|
}
|
|
@@ -2345,7 +2362,7 @@ function Dot (runner) {
|
|
|
2345
2362
|
process.stdout.write(color('fail', Base.symbols.bang));
|
|
2346
2363
|
});
|
|
2347
2364
|
|
|
2348
|
-
runner.
|
|
2365
|
+
runner.once('end', function () {
|
|
2349
2366
|
console.log();
|
|
2350
2367
|
self.epilogue();
|
|
2351
2368
|
});
|
|
@@ -2773,7 +2790,7 @@ function List (runner) {
|
|
|
2773
2790
|
console.log(JSON.stringify(['fail', test]));
|
|
2774
2791
|
});
|
|
2775
2792
|
|
|
2776
|
-
runner.
|
|
2793
|
+
runner.once('end', function () {
|
|
2777
2794
|
process.stdout.write(JSON.stringify(['end', self.stats]));
|
|
2778
2795
|
});
|
|
2779
2796
|
}
|
|
@@ -2843,7 +2860,7 @@ function JSONReporter (runner) {
|
|
|
2843
2860
|
pending.push(test);
|
|
2844
2861
|
});
|
|
2845
2862
|
|
|
2846
|
-
runner.
|
|
2863
|
+
runner.once('end', function () {
|
|
2847
2864
|
var obj = {
|
|
2848
2865
|
stats: self.stats,
|
|
2849
2866
|
tests: tests.map(clean),
|
|
@@ -2977,7 +2994,7 @@ function Landing (runner) {
|
|
|
2977
2994
|
stream.write('\u001b[0m');
|
|
2978
2995
|
});
|
|
2979
2996
|
|
|
2980
|
-
runner.
|
|
2997
|
+
runner.once('end', function () {
|
|
2981
2998
|
cursor.show();
|
|
2982
2999
|
console.log();
|
|
2983
3000
|
self.epilogue();
|
|
@@ -3048,7 +3065,7 @@ function List (runner) {
|
|
|
3048
3065
|
console.log(color('fail', ' %d) %s'), ++n, test.fullTitle());
|
|
3049
3066
|
});
|
|
3050
3067
|
|
|
3051
|
-
runner.
|
|
3068
|
+
runner.once('end', self.epilogue.bind(self));
|
|
3052
3069
|
}
|
|
3053
3070
|
|
|
3054
3071
|
/**
|
|
@@ -3152,7 +3169,7 @@ function Markdown (runner) {
|
|
|
3152
3169
|
buf += '```\n\n';
|
|
3153
3170
|
});
|
|
3154
3171
|
|
|
3155
|
-
runner.
|
|
3172
|
+
runner.once('end', function () {
|
|
3156
3173
|
process.stdout.write('# TOC\n');
|
|
3157
3174
|
process.stdout.write(generateTOC(runner.suite));
|
|
3158
3175
|
process.stdout.write(buf);
|
|
@@ -3193,7 +3210,7 @@ function Min (runner) {
|
|
|
3193
3210
|
process.stdout.write('\u001b[1;3H');
|
|
3194
3211
|
});
|
|
3195
3212
|
|
|
3196
|
-
runner.
|
|
3213
|
+
runner.once('end', this.epilogue.bind(this));
|
|
3197
3214
|
}
|
|
3198
3215
|
|
|
3199
3216
|
/**
|
|
@@ -3258,7 +3275,7 @@ function NyanCat (runner) {
|
|
|
3258
3275
|
self.draw();
|
|
3259
3276
|
});
|
|
3260
3277
|
|
|
3261
|
-
runner.
|
|
3278
|
+
runner.once('end', function () {
|
|
3262
3279
|
Base.cursor.show();
|
|
3263
3280
|
for (var i = 0; i < self.numberOfLines; i++) {
|
|
3264
3281
|
write('\n');
|
|
@@ -3553,7 +3570,7 @@ function Progress (runner, options) {
|
|
|
3553
3570
|
|
|
3554
3571
|
// tests are complete, output some stats
|
|
3555
3572
|
// and the failures if any
|
|
3556
|
-
runner.
|
|
3573
|
+
runner.once('end', function () {
|
|
3557
3574
|
cursor.show();
|
|
3558
3575
|
console.log();
|
|
3559
3576
|
self.epilogue();
|
|
@@ -3641,7 +3658,7 @@ function Spec (runner) {
|
|
|
3641
3658
|
console.log(indent() + color('fail', ' %d) %s'), ++n, test.title);
|
|
3642
3659
|
});
|
|
3643
3660
|
|
|
3644
|
-
runner.
|
|
3661
|
+
runner.once('end', self.epilogue.bind(self));
|
|
3645
3662
|
}
|
|
3646
3663
|
|
|
3647
3664
|
/**
|
|
@@ -3703,7 +3720,7 @@ function TAP (runner) {
|
|
|
3703
3720
|
}
|
|
3704
3721
|
});
|
|
3705
3722
|
|
|
3706
|
-
runner.
|
|
3723
|
+
runner.once('end', function () {
|
|
3707
3724
|
console.log('# tests ' + (passes + failures));
|
|
3708
3725
|
console.log('# pass ' + passes);
|
|
3709
3726
|
console.log('# fail ' + failures);
|
|
@@ -3803,7 +3820,7 @@ function XUnit (runner, options) {
|
|
|
3803
3820
|
tests.push(test);
|
|
3804
3821
|
});
|
|
3805
3822
|
|
|
3806
|
-
runner.
|
|
3823
|
+
runner.once('end', function () {
|
|
3807
3824
|
self.write(tag('testsuite', {
|
|
3808
3825
|
name: suiteName,
|
|
3809
3826
|
tests: stats.tests,
|
|
@@ -4015,7 +4032,7 @@ Runnable.prototype.slow = function (ms) {
|
|
|
4015
4032
|
if (typeof ms === 'string') {
|
|
4016
4033
|
ms = milliseconds(ms);
|
|
4017
4034
|
}
|
|
4018
|
-
debug('
|
|
4035
|
+
debug('slow %d', ms);
|
|
4019
4036
|
this._slow = ms;
|
|
4020
4037
|
return this;
|
|
4021
4038
|
};
|
|
@@ -4054,6 +4071,24 @@ Runnable.prototype.isPending = function () {
|
|
|
4054
4071
|
return this.pending || (this.parent && this.parent.isPending());
|
|
4055
4072
|
};
|
|
4056
4073
|
|
|
4074
|
+
/**
|
|
4075
|
+
* Return `true` if this Runnable has failed.
|
|
4076
|
+
* @return {boolean}
|
|
4077
|
+
* @private
|
|
4078
|
+
*/
|
|
4079
|
+
Runnable.prototype.isFailed = function () {
|
|
4080
|
+
return !this.isPending() && this.state === 'failed';
|
|
4081
|
+
};
|
|
4082
|
+
|
|
4083
|
+
/**
|
|
4084
|
+
* Return `true` if this Runnable has passed.
|
|
4085
|
+
* @return {boolean}
|
|
4086
|
+
* @private
|
|
4087
|
+
*/
|
|
4088
|
+
Runnable.prototype.isPassed = function () {
|
|
4089
|
+
return !this.isPending() && this.state === 'passed';
|
|
4090
|
+
};
|
|
4091
|
+
|
|
4057
4092
|
/**
|
|
4058
4093
|
* Set or get number of retries.
|
|
4059
4094
|
*
|
|
@@ -4582,10 +4617,10 @@ Runner.prototype.failHook = function (hook, err) {
|
|
|
4582
4617
|
hook.title = hook.originalTitle + ' for "' + hook.ctx.currentTest.title + '"';
|
|
4583
4618
|
}
|
|
4584
4619
|
|
|
4585
|
-
this.fail(hook, err);
|
|
4586
4620
|
if (this.suite.bail()) {
|
|
4587
4621
|
this.emit('end');
|
|
4588
4622
|
}
|
|
4623
|
+
this.fail(hook, err);
|
|
4589
4624
|
};
|
|
4590
4625
|
|
|
4591
4626
|
/**
|
|
@@ -5043,21 +5078,25 @@ Runner.prototype.uncaught = function (err) {
|
|
|
5043
5078
|
|
|
5044
5079
|
runnable.clearTimeout();
|
|
5045
5080
|
|
|
5046
|
-
// Ignore errors if
|
|
5047
|
-
|
|
5081
|
+
// Ignore errors if already failed or pending
|
|
5082
|
+
// See #3226
|
|
5083
|
+
if (runnable.isFailed() || runnable.isPending()) {
|
|
5048
5084
|
return;
|
|
5049
5085
|
}
|
|
5086
|
+
// we cannot recover gracefully if a Runnable has already passed
|
|
5087
|
+
// then fails asynchronously
|
|
5088
|
+
var alreadyPassed = runnable.isPassed();
|
|
5089
|
+
// this will change the state to "failed" regardless of the current value
|
|
5050
5090
|
this.fail(runnable, err);
|
|
5091
|
+
if (!alreadyPassed) {
|
|
5092
|
+
// recover from test
|
|
5093
|
+
if (runnable.type === 'test') {
|
|
5094
|
+
this.emit('test end', runnable);
|
|
5095
|
+
this.hookUp('afterEach', this.next);
|
|
5096
|
+
return;
|
|
5097
|
+
}
|
|
5051
5098
|
|
|
5052
|
-
|
|
5053
|
-
if (runnable.type === 'test') {
|
|
5054
|
-
this.emit('test end', runnable);
|
|
5055
|
-
this.hookUp('afterEach', this.next);
|
|
5056
|
-
return;
|
|
5057
|
-
}
|
|
5058
|
-
|
|
5059
|
-
// recover from hooks
|
|
5060
|
-
if (runnable.type === 'hook') {
|
|
5099
|
+
// recover from hooks
|
|
5061
5100
|
var errSuite = this.suite;
|
|
5062
5101
|
// if hook failure is in afterEach block
|
|
5063
5102
|
if (runnable.fullTitle().indexOf('after each') > -1) {
|
|
@@ -5767,22 +5806,15 @@ Test.prototype.clone = function () {
|
|
|
5767
5806
|
(function (process,Buffer){
|
|
5768
5807
|
'use strict';
|
|
5769
5808
|
|
|
5770
|
-
/* eslint-env browser */
|
|
5771
|
-
|
|
5772
5809
|
/**
|
|
5773
5810
|
* Module dependencies.
|
|
5774
5811
|
*/
|
|
5775
5812
|
|
|
5776
|
-
var basename = require('path').basename;
|
|
5777
5813
|
var debug = require('debug')('mocha:watch');
|
|
5778
|
-
var
|
|
5814
|
+
var fs = require('fs');
|
|
5779
5815
|
var glob = require('glob');
|
|
5780
5816
|
var path = require('path');
|
|
5781
5817
|
var join = path.join;
|
|
5782
|
-
var readdirSync = require('fs').readdirSync;
|
|
5783
|
-
var statSync = require('fs').statSync;
|
|
5784
|
-
var watchFile = require('fs').watchFile;
|
|
5785
|
-
var lstatSync = require('fs').lstatSync;
|
|
5786
5818
|
var he = require('he');
|
|
5787
5819
|
|
|
5788
5820
|
/**
|
|
@@ -5827,7 +5859,7 @@ exports.watch = function (files, fn) {
|
|
|
5827
5859
|
var options = { interval: 100 };
|
|
5828
5860
|
files.forEach(function (file) {
|
|
5829
5861
|
debug('file %s', file);
|
|
5830
|
-
watchFile(file, options, function (curr, prev) {
|
|
5862
|
+
fs.watchFile(file, options, function (curr, prev) {
|
|
5831
5863
|
if (prev.mtime < curr.mtime) {
|
|
5832
5864
|
fn(file);
|
|
5833
5865
|
}
|
|
@@ -5861,11 +5893,11 @@ exports.files = function (dir, ext, ret) {
|
|
|
5861
5893
|
|
|
5862
5894
|
var re = new RegExp('\\.(' + ext.join('|') + ')$');
|
|
5863
5895
|
|
|
5864
|
-
readdirSync(dir)
|
|
5896
|
+
fs.readdirSync(dir)
|
|
5865
5897
|
.filter(ignored)
|
|
5866
5898
|
.forEach(function (path) {
|
|
5867
5899
|
path = join(dir, path);
|
|
5868
|
-
if (lstatSync(path).isDirectory()) {
|
|
5900
|
+
if (fs.lstatSync(path).isDirectory()) {
|
|
5869
5901
|
exports.files(path, ext, ret);
|
|
5870
5902
|
} else if (path.match(re)) {
|
|
5871
5903
|
ret.push(path);
|
|
@@ -6236,40 +6268,40 @@ exports.canonicalize = function canonicalize (value, stack, typeHint) {
|
|
|
6236
6268
|
* Lookup file names at the given `path`.
|
|
6237
6269
|
*
|
|
6238
6270
|
* @api public
|
|
6239
|
-
* @param {string}
|
|
6271
|
+
* @param {string} filepath Base path to start searching from.
|
|
6240
6272
|
* @param {string[]} extensions File extensions to look for.
|
|
6241
6273
|
* @param {boolean} recursive Whether or not to recurse into subdirectories.
|
|
6242
6274
|
* @return {string[]} An array of paths.
|
|
6243
6275
|
*/
|
|
6244
|
-
exports.lookupFiles = function lookupFiles (
|
|
6276
|
+
exports.lookupFiles = function lookupFiles (filepath, extensions, recursive) {
|
|
6245
6277
|
var files = [];
|
|
6246
6278
|
|
|
6247
|
-
if (!
|
|
6248
|
-
if (
|
|
6249
|
-
|
|
6279
|
+
if (!fs.existsSync(filepath)) {
|
|
6280
|
+
if (fs.existsSync(filepath + '.js')) {
|
|
6281
|
+
filepath += '.js';
|
|
6250
6282
|
} else {
|
|
6251
|
-
files = glob.sync(
|
|
6283
|
+
files = glob.sync(filepath);
|
|
6252
6284
|
if (!files.length) {
|
|
6253
|
-
throw new Error("cannot resolve path (or pattern) '" +
|
|
6285
|
+
throw new Error("cannot resolve path (or pattern) '" + filepath + "'");
|
|
6254
6286
|
}
|
|
6255
6287
|
return files;
|
|
6256
6288
|
}
|
|
6257
6289
|
}
|
|
6258
6290
|
|
|
6259
6291
|
try {
|
|
6260
|
-
var stat = statSync(
|
|
6292
|
+
var stat = fs.statSync(filepath);
|
|
6261
6293
|
if (stat.isFile()) {
|
|
6262
|
-
return
|
|
6294
|
+
return filepath;
|
|
6263
6295
|
}
|
|
6264
6296
|
} catch (err) {
|
|
6265
6297
|
// ignore error
|
|
6266
6298
|
return;
|
|
6267
6299
|
}
|
|
6268
6300
|
|
|
6269
|
-
readdirSync(
|
|
6270
|
-
file = join(
|
|
6301
|
+
fs.readdirSync(filepath).forEach(function (file) {
|
|
6302
|
+
file = path.join(filepath, file);
|
|
6271
6303
|
try {
|
|
6272
|
-
var stat = statSync(file);
|
|
6304
|
+
var stat = fs.statSync(file);
|
|
6273
6305
|
if (stat.isDirectory()) {
|
|
6274
6306
|
if (recursive) {
|
|
6275
6307
|
files = files.concat(lookupFiles(file, extensions, recursive));
|
|
@@ -6281,7 +6313,7 @@ exports.lookupFiles = function lookupFiles (path, extensions, recursive) {
|
|
|
6281
6313
|
return;
|
|
6282
6314
|
}
|
|
6283
6315
|
var re = new RegExp('\\.(?:' + extensions.join('|') + ')$');
|
|
6284
|
-
if (!stat.isFile() || !re.test(file) || basename(file)[0] === '.') {
|
|
6316
|
+
if (!stat.isFile() || !re.test(file) || path.basename(file)[0] === '.') {
|
|
6285
6317
|
return;
|
|
6286
6318
|
}
|
|
6287
6319
|
files.push(file);
|
|
@@ -6364,7 +6396,7 @@ exports.stackTraceFilter = function () {
|
|
|
6364
6396
|
|
|
6365
6397
|
// Clean up cwd(absolute)
|
|
6366
6398
|
if (/\(?.+:\d+:\d+\)?$/.test(line)) {
|
|
6367
|
-
line = line.replace(cwd, '');
|
|
6399
|
+
line = line.replace('(' + cwd, '(');
|
|
6368
6400
|
}
|
|
6369
6401
|
|
|
6370
6402
|
list.push(line);
|
|
@@ -8797,7 +8829,7 @@ function coerce(val) {
|
|
|
8797
8829
|
},{"ms":54}],45:[function(require,module,exports){
|
|
8798
8830
|
/*!
|
|
8799
8831
|
|
|
8800
|
-
diff v3.
|
|
8832
|
+
diff v3.5.0
|
|
8801
8833
|
|
|
8802
8834
|
Software License Agreement (BSD License)
|
|
8803
8835
|
|
|
@@ -9120,7 +9152,11 @@ return /******/ (function(modules) { // webpackBootstrap
|
|
|
9120
9152
|
return oldPos;
|
|
9121
9153
|
},
|
|
9122
9154
|
/*istanbul ignore start*/ /*istanbul ignore end*/equals: function equals(left, right) {
|
|
9123
|
-
|
|
9155
|
+
if (this.options.comparator) {
|
|
9156
|
+
return this.options.comparator(left, right);
|
|
9157
|
+
} else {
|
|
9158
|
+
return left === right || this.options.ignoreCase && left.toLowerCase() === right.toLowerCase();
|
|
9159
|
+
}
|
|
9124
9160
|
},
|
|
9125
9161
|
/*istanbul ignore start*/ /*istanbul ignore end*/removeEmpty: function removeEmpty(array) {
|
|
9126
9162
|
var ret = [];
|
|
@@ -9183,10 +9219,11 @@ return /******/ (function(modules) { // webpackBootstrap
|
|
|
9183
9219
|
}
|
|
9184
9220
|
}
|
|
9185
9221
|
|
|
9186
|
-
// Special case handle for when one terminal is ignored.
|
|
9187
|
-
// terminal into the prior string and drop the change.
|
|
9222
|
+
// Special case handle for when one terminal is ignored (i.e. whitespace).
|
|
9223
|
+
// For this case we merge the terminal into the prior string and drop the change.
|
|
9224
|
+
// This is only available for string mode.
|
|
9188
9225
|
var lastComponent = components[componentLen - 1];
|
|
9189
|
-
if (componentLen > 1 && (lastComponent.added || lastComponent.removed) && diff.equals('', lastComponent.value)) {
|
|
9226
|
+
if (componentLen > 1 && typeof lastComponent.value === 'string' && (lastComponent.added || lastComponent.removed) && diff.equals('', lastComponent.value)) {
|
|
9190
9227
|
components[componentLen - 2].value += lastComponent.value;
|
|
9191
9228
|
components.pop();
|
|
9192
9229
|
}
|
|
@@ -9464,16 +9501,16 @@ return /******/ (function(modules) { // webpackBootstrap
|
|
|
9464
9501
|
|
|
9465
9502
|
jsonDiff.tokenize = /*istanbul ignore start*/_line.lineDiff /*istanbul ignore end*/.tokenize;
|
|
9466
9503
|
jsonDiff.castInput = function (value) {
|
|
9467
|
-
/*istanbul ignore start*/var /*istanbul ignore end*/
|
|
9468
|
-
|
|
9504
|
+
/*istanbul ignore start*/var _options = /*istanbul ignore end*/this.options,
|
|
9505
|
+
undefinedReplacement = _options.undefinedReplacement,
|
|
9506
|
+
_options$stringifyRep = _options.stringifyReplacer,
|
|
9507
|
+
stringifyReplacer = _options$stringifyRep === undefined ? function (k, v) /*istanbul ignore start*/{
|
|
9508
|
+
return (/*istanbul ignore end*/typeof v === 'undefined' ? undefinedReplacement : v
|
|
9509
|
+
);
|
|
9510
|
+
} : _options$stringifyRep;
|
|
9469
9511
|
|
|
9470
|
-
return typeof value === 'string' ? value : JSON.stringify(canonicalize(value), function (k, v) {
|
|
9471
|
-
if (typeof v === 'undefined') {
|
|
9472
|
-
return undefinedReplacement;
|
|
9473
|
-
}
|
|
9474
9512
|
|
|
9475
|
-
|
|
9476
|
-
}, ' ');
|
|
9513
|
+
return typeof value === 'string' ? value : JSON.stringify(canonicalize(value, null, null, stringifyReplacer), stringifyReplacer, ' ');
|
|
9477
9514
|
};
|
|
9478
9515
|
jsonDiff.equals = function (left, right) {
|
|
9479
9516
|
return (/*istanbul ignore start*/_base2['default'] /*istanbul ignore end*/.prototype.equals.call(jsonDiff, left.replace(/,([\r\n])/g, '$1'), right.replace(/,([\r\n])/g, '$1'))
|
|
@@ -9485,11 +9522,15 @@ return /******/ (function(modules) { // webpackBootstrap
|
|
|
9485
9522
|
}
|
|
9486
9523
|
|
|
9487
9524
|
// This function handles the presence of circular references by bailing out when encountering an
|
|
9488
|
-
// object that is already on the "stack" of items being processed.
|
|
9489
|
-
function canonicalize(obj, stack, replacementStack) {
|
|
9525
|
+
// object that is already on the "stack" of items being processed. Accepts an optional replacer
|
|
9526
|
+
function canonicalize(obj, stack, replacementStack, replacer, key) {
|
|
9490
9527
|
stack = stack || [];
|
|
9491
9528
|
replacementStack = replacementStack || [];
|
|
9492
9529
|
|
|
9530
|
+
if (replacer) {
|
|
9531
|
+
obj = replacer(key, obj);
|
|
9532
|
+
}
|
|
9533
|
+
|
|
9493
9534
|
var i = /*istanbul ignore start*/void 0 /*istanbul ignore end*/;
|
|
9494
9535
|
|
|
9495
9536
|
for (i = 0; i < stack.length; i += 1) {
|
|
@@ -9505,7 +9546,7 @@ return /******/ (function(modules) { // webpackBootstrap
|
|
|
9505
9546
|
canonicalizedObj = new Array(obj.length);
|
|
9506
9547
|
replacementStack.push(canonicalizedObj);
|
|
9507
9548
|
for (i = 0; i < obj.length; i += 1) {
|
|
9508
|
-
canonicalizedObj[i] = canonicalize(obj[i], stack, replacementStack);
|
|
9549
|
+
canonicalizedObj[i] = canonicalize(obj[i], stack, replacementStack, replacer, key);
|
|
9509
9550
|
}
|
|
9510
9551
|
stack.pop();
|
|
9511
9552
|
replacementStack.pop();
|
|
@@ -9521,17 +9562,17 @@ return /******/ (function(modules) { // webpackBootstrap
|
|
|
9521
9562
|
canonicalizedObj = {};
|
|
9522
9563
|
replacementStack.push(canonicalizedObj);
|
|
9523
9564
|
var sortedKeys = [],
|
|
9524
|
-
|
|
9525
|
-
for (
|
|
9565
|
+
_key = /*istanbul ignore start*/void 0 /*istanbul ignore end*/;
|
|
9566
|
+
for (_key in obj) {
|
|
9526
9567
|
/* istanbul ignore else */
|
|
9527
|
-
if (obj.hasOwnProperty(
|
|
9528
|
-
sortedKeys.push(
|
|
9568
|
+
if (obj.hasOwnProperty(_key)) {
|
|
9569
|
+
sortedKeys.push(_key);
|
|
9529
9570
|
}
|
|
9530
9571
|
}
|
|
9531
9572
|
sortedKeys.sort();
|
|
9532
9573
|
for (i = 0; i < sortedKeys.length; i += 1) {
|
|
9533
|
-
|
|
9534
|
-
canonicalizedObj[
|
|
9574
|
+
_key = sortedKeys[i];
|
|
9575
|
+
canonicalizedObj[_key] = canonicalize(obj[_key], stack, replacementStack, replacer, _key);
|
|
9535
9576
|
}
|
|
9536
9577
|
stack.pop();
|
|
9537
9578
|
replacementStack.pop();
|
|
@@ -9560,9 +9601,12 @@ return /******/ (function(modules) { // webpackBootstrap
|
|
|
9560
9601
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
|
|
9561
9602
|
|
|
9562
9603
|
/*istanbul ignore end*/var arrayDiff = /*istanbul ignore start*/exports. /*istanbul ignore end*/arrayDiff = new /*istanbul ignore start*/_base2['default'] /*istanbul ignore end*/();
|
|
9563
|
-
arrayDiff.tokenize =
|
|
9604
|
+
arrayDiff.tokenize = function (value) {
|
|
9564
9605
|
return value.slice();
|
|
9565
9606
|
};
|
|
9607
|
+
arrayDiff.join = arrayDiff.removeEmpty = function (value) {
|
|
9608
|
+
return value;
|
|
9609
|
+
};
|
|
9566
9610
|
|
|
9567
9611
|
function diffArrays(oldArr, newArr, callback) {
|
|
9568
9612
|
return arrayDiff.diff(oldArr, newArr, callback);
|
|
@@ -9624,8 +9668,8 @@ return /******/ (function(modules) { // webpackBootstrap
|
|
|
9624
9668
|
function hunkFits(hunk, toPos) {
|
|
9625
9669
|
for (var j = 0; j < hunk.lines.length; j++) {
|
|
9626
9670
|
var line = hunk.lines[j],
|
|
9627
|
-
operation = line[0],
|
|
9628
|
-
content = line.substr(1);
|
|
9671
|
+
operation = line.length > 0 ? line[0] : ' ',
|
|
9672
|
+
content = line.length > 0 ? line.substr(1) : line;
|
|
9629
9673
|
|
|
9630
9674
|
if (operation === ' ' || operation === '-') {
|
|
9631
9675
|
// Context sanity check
|
|
@@ -9682,8 +9726,8 @@ return /******/ (function(modules) { // webpackBootstrap
|
|
|
9682
9726
|
|
|
9683
9727
|
for (var j = 0; j < _hunk.lines.length; j++) {
|
|
9684
9728
|
var line = _hunk.lines[j],
|
|
9685
|
-
operation = line[0],
|
|
9686
|
-
content = line.substr(1),
|
|
9729
|
+
operation = line.length > 0 ? line[0] : ' ',
|
|
9730
|
+
content = line.length > 0 ? line.substr(1) : line,
|
|
9687
9731
|
delimiter = _hunk.linedelimiters[j];
|
|
9688
9732
|
|
|
9689
9733
|
if (operation === ' ') {
|
|
@@ -9821,16 +9865,16 @@ return /******/ (function(modules) { // webpackBootstrap
|
|
|
9821
9865
|
// Parses the --- and +++ headers, if none are found, no lines
|
|
9822
9866
|
// are consumed.
|
|
9823
9867
|
function parseFileHeader(index) {
|
|
9824
|
-
var
|
|
9825
|
-
var fileHeader = headerPattern.exec(diffstr[i]);
|
|
9868
|
+
var fileHeader = /^(---|\+\+\+)\s+(.*)$/.exec(diffstr[i]);
|
|
9826
9869
|
if (fileHeader) {
|
|
9827
9870
|
var keyPrefix = fileHeader[1] === '---' ? 'old' : 'new';
|
|
9828
|
-
var
|
|
9871
|
+
var data = fileHeader[2].split('\t', 2);
|
|
9872
|
+
var fileName = data[0].replace(/\\\\/g, '\\');
|
|
9829
9873
|
if (/^".*"$/.test(fileName)) {
|
|
9830
9874
|
fileName = fileName.substr(1, fileName.length - 2);
|
|
9831
9875
|
}
|
|
9832
9876
|
index[keyPrefix + 'FileName'] = fileName;
|
|
9833
|
-
index[keyPrefix + 'Header'] =
|
|
9877
|
+
index[keyPrefix + 'Header'] = (data[1] || '').trim();
|
|
9834
9878
|
|
|
9835
9879
|
i++;
|
|
9836
9880
|
}
|
|
@@ -9860,7 +9904,7 @@ return /******/ (function(modules) { // webpackBootstrap
|
|
|
9860
9904
|
if (diffstr[i].indexOf('--- ') === 0 && i + 2 < diffstr.length && diffstr[i + 1].indexOf('+++ ') === 0 && diffstr[i + 2].indexOf('@@') === 0) {
|
|
9861
9905
|
break;
|
|
9862
9906
|
}
|
|
9863
|
-
var operation = diffstr[i][0];
|
|
9907
|
+
var operation = diffstr[i].length == 0 && i != diffstr.length - 1 ? ' ' : diffstr[i][0];
|
|
9864
9908
|
|
|
9865
9909
|
if (operation === '+' || operation === '-' || operation === ' ' || operation === '\\') {
|
|
9866
9910
|
hunk.lines.push(diffstr[i]);
|
|
@@ -9981,27 +10025,19 @@ return /******/ (function(modules) { // webpackBootstrap
|
|
|
9981
10025
|
/*istanbul ignore start*/function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
|
|
9982
10026
|
|
|
9983
10027
|
/*istanbul ignore end*/function calcLineCount(hunk) {
|
|
9984
|
-
var
|
|
10028
|
+
/*istanbul ignore start*/var _calcOldNewLineCount = /*istanbul ignore end*/calcOldNewLineCount(hunk.lines),
|
|
10029
|
+
oldLines = _calcOldNewLineCount.oldLines,
|
|
10030
|
+
newLines = _calcOldNewLineCount.newLines;
|
|
9985
10031
|
|
|
9986
|
-
|
|
9987
|
-
|
|
9988
|
-
|
|
9989
|
-
hunk.lines.forEach(function (line) {
|
|
9990
|
-
if (typeof line !== 'string') {
|
|
9991
|
-
conflicted = true;
|
|
9992
|
-
return;
|
|
9993
|
-
}
|
|
9994
|
-
|
|
9995
|
-
if (line[0] === '+' || line[0] === ' ') {
|
|
9996
|
-
hunk.newLines++;
|
|
9997
|
-
}
|
|
9998
|
-
if (line[0] === '-' || line[0] === ' ') {
|
|
9999
|
-
hunk.oldLines++;
|
|
10000
|
-
}
|
|
10001
|
-
});
|
|
10002
|
-
|
|
10003
|
-
if (conflicted) {
|
|
10032
|
+
if (oldLines !== undefined) {
|
|
10033
|
+
hunk.oldLines = oldLines;
|
|
10034
|
+
} else {
|
|
10004
10035
|
delete hunk.oldLines;
|
|
10036
|
+
}
|
|
10037
|
+
|
|
10038
|
+
if (newLines !== undefined) {
|
|
10039
|
+
hunk.newLines = newLines;
|
|
10040
|
+
} else {
|
|
10005
10041
|
delete hunk.newLines;
|
|
10006
10042
|
}
|
|
10007
10043
|
}
|
|
@@ -10333,6 +10369,43 @@ return /******/ (function(modules) { // webpackBootstrap
|
|
|
10333
10369
|
return true;
|
|
10334
10370
|
}
|
|
10335
10371
|
|
|
10372
|
+
function calcOldNewLineCount(lines) {
|
|
10373
|
+
var oldLines = 0;
|
|
10374
|
+
var newLines = 0;
|
|
10375
|
+
|
|
10376
|
+
lines.forEach(function (line) {
|
|
10377
|
+
if (typeof line !== 'string') {
|
|
10378
|
+
var myCount = calcOldNewLineCount(line.mine);
|
|
10379
|
+
var theirCount = calcOldNewLineCount(line.theirs);
|
|
10380
|
+
|
|
10381
|
+
if (oldLines !== undefined) {
|
|
10382
|
+
if (myCount.oldLines === theirCount.oldLines) {
|
|
10383
|
+
oldLines += myCount.oldLines;
|
|
10384
|
+
} else {
|
|
10385
|
+
oldLines = undefined;
|
|
10386
|
+
}
|
|
10387
|
+
}
|
|
10388
|
+
|
|
10389
|
+
if (newLines !== undefined) {
|
|
10390
|
+
if (myCount.newLines === theirCount.newLines) {
|
|
10391
|
+
newLines += myCount.newLines;
|
|
10392
|
+
} else {
|
|
10393
|
+
newLines = undefined;
|
|
10394
|
+
}
|
|
10395
|
+
}
|
|
10396
|
+
} else {
|
|
10397
|
+
if (newLines !== undefined && (line[0] === '+' || line[0] === ' ')) {
|
|
10398
|
+
newLines++;
|
|
10399
|
+
}
|
|
10400
|
+
if (oldLines !== undefined && (line[0] === '-' || line[0] === ' ')) {
|
|
10401
|
+
oldLines++;
|
|
10402
|
+
}
|
|
10403
|
+
}
|
|
10404
|
+
});
|
|
10405
|
+
|
|
10406
|
+
return { oldLines: oldLines, newLines: newLines };
|
|
10407
|
+
}
|
|
10408
|
+
|
|
10336
10409
|
|
|
10337
10410
|
|
|
10338
10411
|
/***/ }),
|