File tree 2 files changed +27
-16
lines changed 2 files changed +27
-16
lines changed Original file line number Diff line number Diff line change @@ -53,38 +53,31 @@ function gitRawCommits (rawGitOpts, rawExecOpts) {
53
53
gitOpts . debug ( 'Your git-log command is:\ngit ' + args . join ( ' ' ) )
54
54
}
55
55
56
- let isError = false
57
-
58
56
const child = execFile ( 'git' , args , {
59
57
cwd : execOpts . cwd ,
60
58
maxBuffer : Infinity
59
+ } , function ( err ) {
60
+ if ( err != null ) {
61
+ readable . emit ( 'error' , err )
62
+ }
63
+
64
+ readable . emit ( 'close' )
61
65
} )
62
66
63
67
child . stdout
64
68
. pipe ( split ( DELIMITER + '\n' ) )
65
69
. pipe ( through ( function ( chunk , enc , cb ) {
66
70
readable . push ( chunk )
67
- isError = false
68
71
69
72
cb ( )
70
73
} , function ( cb ) {
71
74
setImmediate ( function ( ) {
72
- if ( ! isError ) {
73
- readable . push ( null )
74
- readable . emit ( 'close' )
75
- }
75
+ readable . push ( null )
76
76
77
77
cb ( )
78
78
} )
79
79
} ) )
80
80
81
- child . stderr
82
- . pipe ( through . obj ( function ( chunk ) {
83
- isError = true
84
- readable . emit ( 'error' , new Error ( chunk ) )
85
- readable . emit ( 'close' )
86
- } ) )
87
-
88
81
return readable
89
82
}
90
83
Original file line number Diff line number Diff line change @@ -29,8 +29,6 @@ describe('git-raw-commits', function () {
29
29
} )
30
30
. pipe ( through ( function ( ) {
31
31
done ( 'should error' )
32
- } , function ( ) {
33
- done ( 'should error' )
34
32
} ) )
35
33
} )
36
34
@@ -192,4 +190,24 @@ describe('git-raw-commits', function () {
192
190
done ( )
193
191
} ) )
194
192
} )
193
+
194
+ it ( 'should emit an error if git is not available' , function ( done ) {
195
+ try {
196
+ var path = process . env . PATH
197
+ process . env . PATH = ''
198
+
199
+ gitRawCommits ( )
200
+ . on ( 'error' , function ( err ) {
201
+ expect ( err ) . to . be . ok // eslint-disable-line no-unused-expressions
202
+ done ( )
203
+ } )
204
+ . pipe ( through ( function ( ) {
205
+ done ( 'should error' )
206
+ } , function ( ) {
207
+ done ( 'should error' )
208
+ } ) )
209
+ } finally {
210
+ process . env . PATH = path
211
+ }
212
+ } )
195
213
} )
You can’t perform that action at this time.
0 commit comments