55 *
66 */
77
8- type InputType = 'file' | 'stdin' ;
8+ type InputType = 'file' | 'stdin' | 'command' ;
99
1010const fs = require ( 'fs' ) ;
1111const os = require ( 'os' ) ;
@@ -22,6 +22,13 @@ const opn = require('opn');
2222
2323module . exports = {
2424
25+ /**
26+ * Get input for the diff
27+ * @param inputType - a string `file`, `stdin`, or `command`
28+ * @param inputArgs - a string array
29+ * @param ignore - a string array
30+ * @param callback - the callback function
31+ */
2532 getInput ( inputType : InputType , inputArgs : any [ ] , ignore : string [ ] , callback ) {
2633 var that = this ;
2734 switch ( inputType ) {
@@ -34,15 +41,15 @@ module.exports = {
3441 break ;
3542
3643 default :
37- that . _runGitDiff ( inputArgs , ignore , callback ) ;
44+ that . runGitDiff ( inputArgs , ignore , callback ) ;
3845 }
3946 } ,
4047
41- _runGitDiff ( gitArgsArr : string [ ] , ignore : string [ ] , callback ) {
48+ runGitDiff ( gitArgsArr : string [ ] , ignore : string [ ] , callback ) {
4249 var gitArgs : string ;
4350
4451 if ( gitArgsArr . length && gitArgsArr [ 0 ] ) {
45- gitArgs = gitArgsArr . map ( function ( arg ) {
52+ gitArgs = gitArgsArr . map ( ( arg ) => {
4653 return '"' + arg + '"' ; // wrap parameters
4754 } ) . join ( ' ' ) ;
4855 } else {
@@ -56,7 +63,7 @@ module.exports = {
5663 var ignoreString = '' ;
5764
5865 if ( ignore ) {
59- ignoreString = ignore . map ( function ( file ) {
66+ ignoreString = ignore . map ( ( file ) => {
6067 return ' ":(exclude)' + file + '" ' ;
6168 } ) . join ( ' ' ) ;
6269 }
@@ -139,13 +146,13 @@ module.exports = {
139146 var filename = 'diff.' + format ;
140147 var filePath = path . resolve ( os . tmpdir ( ) , filename ) ;
141148 utils . writeFile ( filePath , content ) ;
142- opn ( filePath ) ;
149+ opn ( filePath , { wait : false } ) ;
143150 } ,
144151
145152 postToDiffy ( diff , postType , callback ) {
146153 var jsonParams = { udiff : diff } ;
147154
148- http . post ( 'http://diffy.org/api/new' , jsonParams , function ( err , response ) {
155+ http . post ( 'http://diffy.org/api/new' , jsonParams , ( err , response ) => {
149156 if ( err ) {
150157 log . error ( err ) ;
151158 return ;
@@ -159,7 +166,7 @@ module.exports = {
159166 open ( response . url ) ;
160167 return callback ( null , response . url ) ;
161168 } else if ( postType === 'pbcopy' ) {
162- ncp . copy ( response . url , function ( ) {
169+ ncp . copy ( response . url , ( ) => {
163170 return callback ( null , response . url ) ;
164171 } ) ;
165172 }
0 commit comments