File tree Expand file tree Collapse file tree 3 files changed +34
-6
lines changed
Expand file tree Collapse file tree 3 files changed +34
-6
lines changed Original file line number Diff line number Diff line change @@ -71,7 +71,8 @@ Usage: diff2html [options] -- [diff args]
7171| -o | --output | Output destination | ` preview ` , ` stdout ` | ` preview ` |
7272| -u | --diffy | Upload to diffy.org | ` browser ` , ` pbcopy ` , ` print ` | |
7373| -F | --file | Send output to file (overrides output option) | _ [ string] _ | |
74- | --version | | Show version number | | |
74+ | --ig | --ignore | Ignore particular files from the diff | _ [ string] _ | |
75+ | -v | --version | | Show version number | | |
7576| -h | --help | Show help | | |
7677
7778Examples:
@@ -99,6 +100,8 @@ Examples:
99100 - ` //diff2html-synchronisedScroll ` - writes code to support selected scroll interaction, must be within a ` <script> ` block
100101 - ` <!--diff2html-diff--> ` - writes diff content to page
101102
103+ ` diff2htal --ig package-lock.json --ig yarn.lock `
104+ - Ignore ` package-lock.json ` and ` yarn.lock ` from the generated diff
102105
103106_ NOTE_ : notice the ` -- ` in the examples
104107
@@ -108,6 +111,10 @@ This is a developer friendly project, all the contributions are welcome.
108111To contribute just send a pull request with your changes following the guidelines described in ` CONTRIBUTING.md ` .
109112I will try to review them as soon as possible.
110113
114+ ## Developing
115+
116+ Make some changes and then ` node src/main.js ` 😉
117+
111118## License
112119
113120Copyright 2014-2019 Rodrigo Fernandes. Released under the terms of the MIT license.
Original file line number Diff line number Diff line change 2626 * Input
2727 */
2828
29- Diff2HtmlInterface . prototype . getInput = function getInput ( inputType , inputArgs , callback ) {
29+ Diff2HtmlInterface . prototype . getInput = function getInput ( inputType , inputArgs , ignore , callback ) {
3030 var that = this ;
3131 switch ( inputType ) {
3232 case 'file' :
3838 break ;
3939
4040 default :
41- that . _runGitDiff ( inputArgs , callback ) ;
41+ that . _runGitDiff ( inputArgs , ignore , callback ) ;
4242 }
4343 } ;
4444
45- Diff2HtmlInterface . prototype . _runGitDiff = function ( gitArgsArr , callback ) {
45+ Diff2HtmlInterface . prototype . _runGitDiff = function ( gitArgsArr , ignore , callback ) {
4646 var gitArgs ;
47+
4748 if ( gitArgsArr . length && gitArgsArr [ 0 ] ) {
4849 gitArgs = gitArgsArr . map ( function ( arg ) {
4950 return '"' + arg + '"' ; // wrap parameters
5657 gitArgs += ' --no-color' ;
5758 }
5859
59- var diffCommand = 'git diff ' + gitArgs ;
60+ var ignoreString = '' ;
61+
62+ if ( ignore ) {
63+ ignoreString = ignore . map ( function ( file ) {
64+ return ' ":(exclude)' + file + '" ' ;
65+ } ) . join ( ' ' ) ;
66+ }
67+
68+ var diffCommand = 'git diff ' + gitArgs + ignoreString ;
69+
6070 return callback ( null , utils . runCmd ( diffCommand ) ) ;
6171 } ;
6272
Original file line number Diff line number Diff line change @@ -137,13 +137,24 @@ var argv = yargs.usage('Usage: diff2html [options] -- [diff args]')
137137 type : 'string'
138138 }
139139 } )
140+ . options ( {
141+ 'ig' : {
142+ alias : 'ignore' ,
143+ describe : 'ignore a file' ,
144+ nargs : 1 ,
145+ type : 'array'
146+ }
147+ } )
140148 . example ( 'diff2html -s line -f html -d word -i command -o preview -- -M HEAD~1' ,
141149 'diff last commit, line by line, word comparison between lines,' +
142150 'previewed in the browser and input from git diff command' )
143151 . example ( 'diff2html -i file -- my-file-diff.diff' , 'reading the input from a file' )
144152 . example ( 'diff2html -f json -o stdout -- -M HEAD~1' , 'print json format to stdout' )
145153 . example ( 'diff2html -F my-pretty-diff.html -- -M HEAD~1' , 'print to file' )
154+ . example ( 'diff2html --ig -- package-lock.json --ig yarn.lock' ,
155+ 'ignore two particular files when generating the diff' )
146156 . help ( 'h' )
157+ . alias ( 'v' , 'version' )
147158 . alias ( 'h' , 'help' )
148159 . epilog ( '© 2014-' + currentYear + ' rtfpessoa\n' +
149160 'For more information, check out https://diff2html.xyz/\n' +
@@ -193,4 +204,4 @@ function onOutput(err, output) {
193204 }
194205}
195206
196- cli . getInput ( argv . input , argv . _ , onInput ) ;
207+ cli . getInput ( argv . input , argv . _ , argv . ig , onInput ) ;
You can’t perform that action at this time.
0 commit comments