@@ -5,7 +5,6 @@ import {fileURLToPath} from 'node:url';
55import { log } from './logger' ;
66import _ from 'lodash' ;
77import { PLATFORM_NAME_TVOS } from './constants' ;
8- import B from 'bluebird' ;
98import _fs from 'node:fs' ;
109import { waitForCondition } from 'asyncbox' ;
1110import { arch } from 'node:os' ;
@@ -90,7 +89,7 @@ export async function killAppUsingPattern(pgrepPattern: string): Promise<void> {
9089 return true ;
9190 }
9291 } ) ;
93- return ( await B . all ( pidCheckPromises ) ) . every ( ( x ) => x === true ) ;
92+ return ( await Promise . all ( pidCheckPromises ) ) . every ( ( x ) => x === true ) ;
9493 } ,
9594 {
9695 waitMs : 1000 ,
@@ -305,7 +304,7 @@ export async function resetTestProcesses(udid: string, isSimulator: boolean): Pr
305304 processPatterns . push ( `xctest.*${ udid } ` ) ;
306305 }
307306 log . debug ( `Killing running processes '${ processPatterns . join ( ', ' ) } ' for the device ${ udid } ...` ) ;
308- await B . all ( processPatterns . map ( killAppUsingPattern ) ) ;
307+ await Promise . all ( processPatterns . map ( killAppUsingPattern ) ) ;
309308}
310309
311310/**
@@ -341,19 +340,22 @@ export async function getPIDsListeningOnPort(
341340 if ( ! _ . isFunction ( filteringFunc ) ) {
342341 return result ;
343342 }
344- return await B . filter ( result , async ( pid ) => {
345- let stdout : string ;
346- try {
347- ( { stdout} = await exec ( 'ps' , [ '-p' , pid , '-o' , 'command' ] ) ) ;
348- } catch ( e : any ) {
349- if ( e . code === 1 ) {
350- // The process does not exist anymore, there's nothing to filter
351- return false ;
343+ const filtered = await Promise . all (
344+ result . map ( async ( pid ) => {
345+ let stdout : string ;
346+ try {
347+ ( { stdout} = await exec ( 'ps' , [ '-p' , pid , '-o' , 'command' ] ) ) ;
348+ } catch ( e : any ) {
349+ if ( e . code === 1 ) {
350+ // The process does not exist anymore, there's nothing to filter
351+ return null ;
352+ }
353+ throw e ;
352354 }
353- throw e ;
354- }
355- return await filteringFunc ( stdout ) ;
356- } ) ;
355+ return ( await filteringFunc ( stdout ) ) ? pid : null ;
356+ } ) ,
357+ ) ;
358+ return filtered . filter ( ( pid ) : pid is string => Boolean ( pid ) ) ;
357359}
358360
359361// Private functions
0 commit comments