11import { spawn , SpawnOptions } from 'node:child_process' ;
22import * as child_process from 'node:child_process' ;
3- import { concat , defer , EMPTY , from , lastValueFrom , catchError , repeat } from 'rxjs' ;
43import { getGlobalVariable , getGlobalVariablesEnv } from './env' ;
54import treeKill from 'tree-kill' ;
65import { delimiter , join , resolve } from 'node:path' ;
@@ -310,7 +309,7 @@ export async function execAndCaptureError(
310309 }
311310}
312311
313- export function execAndWaitForOutputToMatch (
312+ export async function execAndWaitForOutputToMatch (
314313 cmd : string ,
315314 args : string [ ] ,
316315 match : RegExp ,
@@ -322,15 +321,24 @@ export function execAndWaitForOutputToMatch(
322321 // happened just before the build (e.g. `git clean`).
323322 // This seems to be due to host file system differences, see
324323 // https://nodejs.org/docs/latest/api/fs.html#fs_caveats
325- return lastValueFrom (
326- concat (
327- from ( _exec ( { waitForMatch : match , env } , cmd , args ) ) ,
328- defer ( ( ) => waitForAnyProcessOutputToMatch ( match , 2500 ) ) . pipe (
329- repeat ( 20 ) ,
330- catchError ( ( ) => EMPTY ) ,
331- ) ,
332- ) ,
333- ) ;
324+ const maxRetries = 20 ;
325+ let lastError ;
326+
327+ try {
328+ return await _exec ( { waitForMatch : match , env } , cmd , args ) ;
329+ } catch ( e ) {
330+ lastError = e ;
331+ }
332+
333+ for ( let i = 0 ; i < maxRetries ; i ++ ) {
334+ try {
335+ return await waitForAnyProcessOutputToMatch ( match , 2500 ) ;
336+ } catch ( e ) {
337+ lastError = e ;
338+ }
339+ }
340+
341+ throw lastError ;
334342 } else {
335343 return _exec ( { waitForMatch : match , env } , cmd , args ) ;
336344 }
0 commit comments