File tree Expand file tree Collapse file tree 2 files changed +9
-6
lines changed Expand file tree Collapse file tree 2 files changed +9
-6
lines changed Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ const indentString = require('indent-string');
33const stripAnsi = require ( 'strip-ansi' ) ;
44const chalk = require ( 'chalk' ) ;
55const diff = require ( 'diff' ) ;
6+ const DiffMatchPatch = require ( 'diff-match-patch' ) ;
67
78const cleanUp = line => {
89 if ( line [ 0 ] === '+' ) {
@@ -46,18 +47,19 @@ module.exports = err => {
4647 }
4748
4849 if ( err . actualType === 'string' && err . expectedType === 'string' ) {
49- const patch = diff . diffChars ( stripAnsi ( err . actual ) , stripAnsi ( err . expected ) ) ;
50+ const diffMatchPatch = new DiffMatchPatch ( ) ;
51+ const patch = diffMatchPatch . diff_main ( stripAnsi ( err . actual ) , stripAnsi ( err . expected ) ) ;
5052 const msg = patch
5153 . map ( part => {
52- if ( part . added ) {
53- return chalk . bgGreen . black ( part . value ) ;
54+ if ( part [ 0 ] === 1 ) {
55+ return chalk . bgGreen . black ( part [ 1 ] ) ;
5456 }
5557
56- if ( part . removed ) {
57- return chalk . bgRed . black ( part . value ) ;
58+ if ( part [ 0 ] === - 1 ) {
59+ return chalk . bgRed . black ( part [ 1 ] ) ;
5860 }
5961
60- return chalk . red ( part . value ) ;
62+ return chalk . red ( part [ 1 ] ) ;
6163 } )
6264 . join ( '' ) ;
6365
Original file line number Diff line number Diff line change 115115 "currently-unhandled" : " ^0.4.1" ,
116116 "debug" : " ^2.2.0" ,
117117 "diff" : " ^3.0.1" ,
118+ "diff-match-patch" : " ^1.0.0" ,
118119 "dot-prop" : " ^4.1.0" ,
119120 "empower-core" : " ^0.6.1" ,
120121 "equal-length" : " ^1.0.0" ,
You can’t perform that action at this time.
0 commit comments