1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | exports.diffPatch = void 0;
|
4 | const color_1 = require("./color");
|
5 | async function diffPatch(filename, text1, text2) {
|
6 | const JsDiff = await Promise.resolve().then(() => require('diff'));
|
7 | return JsDiff.createPatch(filename, text1, text2, '', '').split('\n').map(line => {
|
8 | if (line.indexOf('-') === 0 && line.indexOf('---') !== 0) {
|
9 | line = color_1.strong(color_1.failure(line));
|
10 | }
|
11 | else if (line.indexOf('+') === 0 && line.indexOf('+++') !== 0) {
|
12 | line = color_1.strong(color_1.input(line));
|
13 | }
|
14 | return line;
|
15 | }).slice(2).join('\n');
|
16 | }
|
17 | exports.diffPatch = diffPatch;
|