(
root: Root,
message: string,
options?: {
color?: TextProps['color'];
exitCode?: number;
beforeExit?: () => Promise<void>;
},
)
| 78 | * through the React tree instead. |
| 79 | */ |
| 80 | export async function exitWithMessage( |
| 81 | root: Root, |
| 82 | message: string, |
| 83 | options?: { |
| 84 | color?: TextProps['color']; |
| 85 | exitCode?: number; |
| 86 | beforeExit?: () => Promise<void>; |
| 87 | }, |
| 88 | ): Promise<never> { |
| 89 | const { Text } = await import('@anthropic/ink'); |
| 90 | const color = options?.color; |
| 91 | const exitCode = options?.exitCode ?? 1; |
| 92 | root.render(color ? <Text color={color}>{message}</Text> : <Text>{message}</Text>); |
| 93 | root.unmount(); |
| 94 | await options?.beforeExit?.(); |
| 95 | // eslint-disable-next-line custom-rules/no-process-exit -- exit after Ink unmount |
| 96 | process.exit(exitCode); |
| 97 | } |
| 98 | |
| 99 | /** |
| 100 | * Show a setup dialog wrapped in AppStateProvider + KeybindingSetup. |
no test coverage detected