This commit is contained in:
Simon Priet
2021-09-05 22:53:58 +02:00
commit 9e2991e668
17888 changed files with 1263126 additions and 0 deletions

View File

@@ -0,0 +1,33 @@
'use strict';Object.defineProperty(exports, "__esModule", { value: true });exports.default =
unifiedDiff;var _diff = require('diff');function unifiedDiff(actual, expected, colorFns) {
var indent = ' ';
function cleanUp(line) {
if (line.length === 0) {
return '';
}
if (line[0] === '+') {
return indent + colorFns.diffAdded(line);
}
if (line[0] === '-') {
return indent + colorFns.diffRemoved(line);
}
if (line.match(/\@\@/)) {
return null;
}
if (line.match(/\\ No newline/)) {
return null;
}
return indent + line;
}
function notBlank(line) {
return typeof line !== 'undefined' && line !== null;
}
var msg = (0, _diff.createPatch)('string', actual, expected);
var lines = msg.split('\n').splice(4);
return '\n' + indent +
colorFns.diffAdded('+ expected') + ' ' +
colorFns.diffRemoved('- actual') +
'\n\n' +
lines.map(cleanUp).filter(notBlank).join('\n');
}