UI for Zipcoin Blue

diff.js 847B

1234567891011121314151617181920
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. const tslib_1 = require("tslib");
  4. const chalk_1 = require("chalk");
  5. function diffPatch(filename, text1, text2) {
  6. return tslib_1.__awaiter(this, void 0, void 0, function* () {
  7. const JsDiff = yield Promise.resolve().then(() => require('diff'));
  8. return JsDiff.createPatch(filename, text1, text2, '', '').split('\n').map((line) => {
  9. if (line.indexOf('-') === 0 && line.indexOf('---') !== 0) {
  10. line = chalk_1.default.bold(chalk_1.default.red(line));
  11. }
  12. else if (line.indexOf('+') === 0 && line.indexOf('+++') !== 0) {
  13. line = chalk_1.default.bold(chalk_1.default.green(line));
  14. }
  15. return line;
  16. }).slice(2).join('\n');
  17. });
  18. }
  19. exports.diffPatch = diffPatch;