@@ -4,7 +4,7 @@ import * as path from 'path';
44
55import * as clipboardy from 'clipboardy' ;
66import open = require( 'open' ) ;
7- import { Diff2Html } from 'diff2html' ;
7+ import { parse , html , Diff2HtmlConfig } from 'diff2html' ;
88
99import * as http from './http-utils' ;
1010import * as log from './logger' ;
@@ -26,10 +26,10 @@ function prepareHTML(diffHTMLContent: string, config: Configuration): string {
2626
2727 const diff2htmlPath = path . join ( path . dirname ( require . resolve ( 'diff2html' ) ) , '..' ) ;
2828
29- const cssFilePath = path . resolve ( diff2htmlPath , 'dist ' , 'diff2html.min.css' ) ;
29+ const cssFilePath = path . resolve ( diff2htmlPath , 'bundles' , 'css ', 'diff2html.min.css' ) ;
3030 const cssContent = utils . readFile ( cssFilePath ) ;
3131
32- const jsUiFilePath = path . resolve ( diff2htmlPath , 'dist ' , 'diff2html-ui.min.js' ) ;
32+ const jsUiFilePath = path . resolve ( diff2htmlPath , 'bundles ' , 'js' , ' diff2html-ui-slim .min.js') ;
3333 const jsUiContent = utils . readFile ( jsUiFilePath ) ;
3434
3535 /* HACK:
@@ -40,16 +40,16 @@ function prepareHTML(diffHTMLContent: string, config: Configuration): string {
4040 { searchValue : '<!--diff2html-css-->' , replaceValue : `<style>\n${ cssContent } \n</style>` } ,
4141 { searchValue : '<!--diff2html-js-ui-->' , replaceValue : `<script>\n${ jsUiContent } \n</script>` } ,
4242 {
43- searchValue : '//diff2html-fileListCloseable ' ,
44- replaceValue : `diff2htmlUi.fileListCloseable("#diff", ${ config . showFilesOpen } );` ,
43+ searchValue : '//diff2html-fileListToggle ' ,
44+ replaceValue : `diff2htmlUi.fileListToggle( ${ config . showFilesOpen } );` ,
4545 } ,
4646 {
4747 searchValue : '//diff2html-synchronisedScroll' ,
48- replaceValue : `diff2htmlUi .synchronisedScroll("#diff", ${ config . synchronisedScroll } );`,
48+ replaceValue : config . synchronisedScroll ? `diff2htmlUi .synchronisedScroll( );` : '' ,
4949 } ,
5050 {
5151 searchValue : '//diff2html-highlightCode' ,
52- replaceValue : config . highlightCode ? `diff2htmlUi.highlightCode("#diff" );` : '' ,
52+ replaceValue : config . highlightCode ? `diff2htmlUi.highlightCode();` : '' ,
5353 } ,
5454 { searchValue : '<!--diff2html-diff-->' , replaceValue : diffHTMLContent } ,
5555 ] . reduce (
@@ -78,15 +78,15 @@ export async function getInput(inputType: InputType, inputArgs: string[], ignore
7878 }
7979}
8080
81- export function getOutput ( options : Diff2Html . Options , config : Configuration , input : string ) : string {
81+ export function getOutput ( options : Diff2HtmlConfig , config : Configuration , input : string ) : string {
8282 if ( config . htmlWrapperTemplate && ! fs . existsSync ( config . htmlWrapperTemplate ) ) {
8383 throw new Error ( `Template ('${ config . htmlWrapperTemplate } ') not found!` ) ;
8484 }
8585
86- const diffJson = Diff2Html . getJsonFromDiff ( input , options ) ;
86+ const diffJson = parse ( input , options ) ;
8787
8888 if ( config . formatType === 'html' ) {
89- const htmlContent = Diff2Html . getPrettyHtml ( diffJson , { ...options , inputFormat : 'json' } ) ;
89+ const htmlContent = html ( diffJson , { ...options } ) ;
9090 return prepareHTML ( htmlContent , config ) ;
9191 } else if ( config . formatType === 'json' ) {
9292 return JSON . stringify ( diffJson ) ;
0 commit comments