@@ -130,6 +130,11 @@ function parseArgs() {
130
130
default : 1 ,
131
131
description : 'number of parallel jobs to run' ,
132
132
} ,
133
+ retry : {
134
+ type : 'number' ,
135
+ default : 0 ,
136
+ description : 'number of times to retry failing jobs' ,
137
+ } ,
133
138
parallel : {
134
139
type : 'boolean' ,
135
140
default : false ,
@@ -202,6 +207,7 @@ async function main() {
202
207
while ( queue . length ) {
203
208
const project = queue . shift ( ) ;
204
209
if ( ! project ) break ;
210
+
205
211
let stdout , stderr ;
206
212
try {
207
213
runningProjects . add ( project ) ;
@@ -212,6 +218,7 @@ async function main() {
212
218
__filename ,
213
219
project ,
214
220
'--skip-pack' ,
221
+ `--retry=${ args . retry } ` ,
215
222
...( args . live ? [ '--live' ] : [ ] ) ,
216
223
...( args . verbose ? [ '--verbose' ] : [ ] ) ,
217
224
...( args . deploy ? [ '--deploy' ] : [ ] ) ,
@@ -245,7 +252,7 @@ async function main() {
245
252
console . error ( '\n' ) ;
246
253
247
254
try {
248
- await fn ( ) ;
255
+ await withRetry ( fn , project , state . retry )
249
256
console . error ( `✅ - Successfully ran ${ project } ` ) ;
250
257
} catch ( err ) {
251
258
if ( err && ( err as any ) . shortMessage ) {
@@ -268,6 +275,18 @@ async function main() {
268
275
process . exit ( 0 ) ;
269
276
}
270
277
278
+ async function withRetry ( fn : ( ) => Promise < void > , identifier : string , retryAmount : number ) : Promise < void > {
279
+ do {
280
+ try {
281
+ return await fn ( )
282
+ } catch ( err ) {
283
+ console . error ( `${ identifier } failed due to ${ err } ; retries left ${ retryAmount } ` )
284
+ }
285
+
286
+ retryAmount -- ;
287
+ } while ( retryAmount > 0 )
288
+ }
289
+
271
290
function centerPad ( text : string , width = text . length , char = ' ' ) : string {
272
291
return text . padStart ( Math . floor ( ( width + text . length ) / 2 ) , char ) . padEnd ( width , char ) ;
273
292
}
0 commit comments