UNPKG

709 BJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3exports.diffPatch = void 0;
4const color_1 = require("./color");
5async 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}
17exports.diffPatch = diffPatch;