11import { runCmd } from '../../utils/exec.ts' ;
2+ import type { ExecResult } from '../../utils/exec.ts' ;
23import { AppError } from '../../utils/errors.ts' ;
34import type { DeviceInfo } from '../../utils/device.ts' ;
45import { Deadline , retryWithPolicy } from '../../utils/retry.ts' ;
@@ -212,8 +213,8 @@ export async function ensureBootedSimulator(device: DeviceInfo): Promise<void> {
212213 const state = await getSimulatorState ( device . id ) ;
213214 if ( state === 'Booted' ) return ;
214215 const deadline = Deadline . fromTimeoutMs ( IOS_BOOT_TIMEOUT_MS ) ;
215- let bootResult : { stdout : string ; stderr : string ; exitCode : number } | null = null ;
216- let bootStatusResult : { stdout : string ; stderr : string ; exitCode : number } | null = null ;
216+ let bootResult : ExecResult | undefined ;
217+ let bootStatusResult : ExecResult | undefined ;
217218 try {
218219 await retryWithPolicy (
219220 async ( ) => {
@@ -264,10 +265,16 @@ export async function ensureBootedSimulator(device: DeviceInfo): Promise<void> {
264265 { deadline } ,
265266 ) ;
266267 } catch ( error ) {
268+ const bootStdout = bootResult ?. stdout ;
269+ const bootStderr = bootResult ?. stderr ;
270+ const bootExitCode = bootResult ?. exitCode ;
271+ const bootstatusStdout = bootStatusResult ?. stdout ;
272+ const bootstatusStderr = bootStatusResult ?. stderr ;
273+ const bootstatusExitCode = bootStatusResult ?. exitCode ;
267274 const reason = classifyBootFailure ( {
268275 error,
269- stdout : bootStatusResult ?. stdout ?? bootResult ?. stdout ,
270- stderr : bootStatusResult ?. stderr ?? bootResult ?. stderr ,
276+ stdout : bootstatusStdout ?? bootStdout ,
277+ stderr : bootstatusStderr ?? bootStderr ,
271278 } ) ;
272279 throw new AppError ( 'COMMAND_FAILED' , 'iOS simulator failed to boot' , {
273280 platform : 'ios' ,
@@ -276,13 +283,13 @@ export async function ensureBootedSimulator(device: DeviceInfo): Promise<void> {
276283 elapsedMs : deadline . elapsedMs ( ) ,
277284 reason,
278285 boot : bootResult
279- ? { exitCode : bootResult . exitCode , stdout : bootResult . stdout , stderr : bootResult . stderr }
286+ ? { exitCode : bootExitCode , stdout : bootStdout , stderr : bootStderr }
280287 : undefined ,
281288 bootstatus : bootStatusResult
282289 ? {
283- exitCode : bootStatusResult . exitCode ,
284- stdout : bootStatusResult . stdout ,
285- stderr : bootStatusResult . stderr ,
290+ exitCode : bootstatusExitCode ,
291+ stdout : bootstatusStdout ,
292+ stderr : bootstatusStderr ,
286293 }
287294 : undefined ,
288295 } ) ;
0 commit comments