( executor: CommandExecutor, fileSystem?: FileSystemExecutor, )
| 43 | } |
| 44 | |
| 45 | export function createLaunchMacAppExecutor( |
| 46 | executor: CommandExecutor, |
| 47 | fileSystem?: FileSystemExecutor, |
| 48 | ): NonStreamingExecutor<LaunchMacAppParams, LaunchMacAppResult> { |
| 49 | return async (params) => { |
| 50 | const baseArtifacts = { appPath: params.appPath }; |
| 51 | |
| 52 | const fileExistsValidation = validateFileExists(params.appPath, fileSystem); |
| 53 | if (!fileExistsValidation.isValid) { |
| 54 | return buildLaunchFailure( |
| 55 | baseArtifacts, |
| 56 | fileExistsValidation.errorMessage ?? `File not found: '${params.appPath}'`, |
| 57 | ); |
| 58 | } |
| 59 | |
| 60 | log('info', `Starting launch macOS app request for ${params.appPath}`); |
| 61 | |
| 62 | try { |
| 63 | const result = await launchMacApp(params.appPath, executor, { args: params.launchArgs }); |
| 64 | |
| 65 | if (!result.success) { |
| 66 | return buildLaunchFailure( |
| 67 | baseArtifacts, |
| 68 | `Launch macOS app operation failed: ${result.error}`, |
| 69 | ); |
| 70 | } |
| 71 | |
| 72 | return buildLaunchSuccess({ |
| 73 | ...baseArtifacts, |
| 74 | ...(result.bundleId ? { bundleId: result.bundleId } : {}), |
| 75 | ...(result.processId !== undefined ? { processId: result.processId } : {}), |
| 76 | }); |
| 77 | } catch (error) { |
| 78 | return buildLaunchFailure( |
| 79 | baseArtifacts, |
| 80 | `Launch macOS app operation failed: ${toErrorMessage(error)}`, |
| 81 | ); |
| 82 | } |
| 83 | }; |
| 84 | } |
| 85 | |
| 86 | export const schema = launchMacAppSchema.shape; |
| 87 |
no test coverage detected