UNPKG

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