@@ -53,22 +53,26 @@ commander
53
53
. description ( 'execute a full happo run' )
54
54
. action ( async ( sha ) => {
55
55
let usedSha = sha || generateDevSha ( ) ;
56
+
56
57
if ( ! sha ) {
57
58
new Logger ( ) . info (
58
59
`No [sha] provided. A temporary one will be used in place: "${ usedSha } ".` ,
59
60
) ;
60
61
}
62
+
61
63
if ( commander . only ) {
62
64
usedSha = `${ usedSha } -${ commander . only } ` ;
63
65
}
66
+
64
67
const isAsync = commander . async || HAPPO_IS_ASYNC ;
65
68
await runCommand ( usedSha , await loadUserConfig ( commander . config ) , {
66
69
only : commander . only ,
67
70
link : commander . link ,
68
71
isAsync,
69
72
message : commander . message ,
70
73
} ) ;
71
- process . exit ( 0 ) ;
74
+
75
+ process . exitCode = 0 ;
72
76
} ) ;
73
77
74
78
commander
@@ -95,9 +99,9 @@ commander
95
99
. description ( 'check if there is a report for a specific sha' )
96
100
. action ( async ( sha ) => {
97
101
if ( await hasReportCommand ( sha , await loadUserConfig ( commander . config ) ) ) {
98
- process . exit ( 0 ) ;
102
+ process . exitCode = 0 ;
99
103
} else {
100
- process . exit ( 1 ) ;
104
+ process . exitCode = 1 ;
101
105
}
102
106
} ) ;
103
107
@@ -110,7 +114,8 @@ commander
110
114
sha,
111
115
...( await loadUserConfig ( commander . config ) ) ,
112
116
} ) ;
113
- process . exit ( 0 ) ;
117
+
118
+ process . exitCode = 0 ;
114
119
} ) ;
115
120
116
121
commander
@@ -130,10 +135,6 @@ commander
130
135
isAsync,
131
136
fallbackShas,
132
137
} ) ;
133
- if ( isAsync ) {
134
- new Logger ( ) . info ( `Async comparison created with ID=${ result . id } ` ) ;
135
- process . exit ( 0 ) ;
136
- }
137
138
if ( commander . link && process . env . HAPPO_GITHUB_USER_CREDENTIALS ) {
138
139
await postGithubComment ( {
139
140
link : commander . link ,
@@ -142,11 +143,19 @@ commander
142
143
githubApiUrl : config . githubApiUrl ,
143
144
} ) ;
144
145
}
146
+
147
+ if ( isAsync ) {
148
+ new Logger ( ) . info ( `Async comparison created with ID=${ result . id } ` ) ;
149
+ process . exitCode = 0 ;
150
+ return ;
151
+ }
152
+
145
153
new Logger ( ) . info ( result . summary ) ;
154
+
146
155
if ( result . equal ) {
147
- process . exit ( 0 ) ;
156
+ process . exitCode = 0 ;
148
157
} else {
149
- process . exit ( 113 ) ;
158
+ process . exitCode = 113 ;
150
159
}
151
160
} ) ;
152
161
@@ -163,20 +172,22 @@ commander
163
172
} ,
164
173
await loadUserConfig ( commander . config ) ,
165
174
) ;
175
+
166
176
new Logger ( ) . info ( result . id ) ;
167
177
} ) ;
168
178
169
179
commander . on ( 'command:*' , ( cmd ) => {
170
180
console . log ( `Invalid command: "${ cmd } "\n` ) ;
171
181
commander . outputHelp ( ) ;
172
- process . exit ( 1 ) ;
182
+ process . exitCode = 1 ;
173
183
} ) ;
174
184
175
185
export default function executeCli ( argv ) {
176
186
if ( ! argv . slice ( 2 ) . length ) {
177
187
commander . outputHelp ( ) ;
178
- process . exit ( 1 ) ;
188
+ process . exitCode = 1 ;
179
189
return ;
180
190
}
191
+
181
192
return commander . parse ( argv ) ;
182
193
}
0 commit comments