File tree Expand file tree Collapse file tree 2 files changed +19
-7
lines changed
Expand file tree Collapse file tree 2 files changed +19
-7
lines changed 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 ;
4747 if ( gitArgsArr . length && gitArgsArr [ 0 ] ) {
4848 gitArgs = gitArgsArr . map ( function ( arg ) {
49- return '"' + arg + '"' ; // wrap parameters
49+ return '"' + ( ignore ? ':(exclude)' : '' ) + arg + '"' ; // wrap parameters
5050 } ) . join ( ' ' ) ;
5151 } else {
5252 gitArgs = '-M -C HEAD' ;
5353 }
5454
55- if ( gitArgs . indexOf ( '--no-color' ) < 0 ) {
55+ if ( ! ignore && gitArgs . indexOf ( '--no-color' ) < 0 ) {
5656 gitArgs += ' --no-color' ;
5757 }
5858
59- var diffCommand = 'git diff ' + gitArgs ;
59+ var diffCommand = 'git diff ' + ( ignore ? '--no-color ' : '' ) + gitArgs ;
60+
6061 return callback ( null , utils . runCmd ( diffCommand ) ) ;
6162 } ;
6263
Original file line number Diff line number Diff line change @@ -137,12 +137,23 @@ 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 : 'boolean' ,
146+ choices : [ true , false ] ,
147+ default : false
148+ }
149+ } )
140150 . example ( 'diff2html -s line -f html -d word -i command -o preview -- -M HEAD~1' ,
141151 'diff last commit, line by line, word comparison between lines,' +
142152 'previewed in the browser and input from git diff command' )
143153 . example ( 'diff2html -i file -- my-file-diff.diff' , 'reading the input from a file' )
144154 . example ( 'diff2html -f json -o stdout -- -M HEAD~1' , 'print json format to stdout' )
145155 . example ( 'diff2html -F my-pretty-diff.html -- -M HEAD~1' , 'print to file' )
156+ . example ( 'diff2html -ig -- package-lock.json yarn.lock' , 'ignore two particular files when generating diff' )
146157 . help ( 'h' )
147158 . alias ( 'h' , 'help' )
148159 . epilog ( '© 2014-' + currentYear + ' rtfpessoa\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