(root: Root, message: string, options?: {
color?: TextProps['color'];
exitCode?: number;
beforeExit?: () => Promise<void>;
})
| 65 | * through the React tree instead. |
| 66 | */ |
| 67 | export async function exitWithMessage(root: Root, message: string, options?: { |
| 68 | color?: TextProps['color']; |
| 69 | exitCode?: number; |
| 70 | beforeExit?: () => Promise<void>; |
| 71 | }): Promise<never> { |
| 72 | const { |
| 73 | Text |
| 74 | } = await import('./ink.js'); |
| 75 | const color = options?.color; |
| 76 | const exitCode = options?.exitCode ?? 1; |
| 77 | root.render(color ? <Text color={color}>{message}</Text> : <Text>{message}</Text>); |
| 78 | root.unmount(); |
| 79 | await options?.beforeExit?.(); |
| 80 | // eslint-disable-next-line custom-rules/no-process-exit -- exit after Ink unmount |
| 81 | process.exit(exitCode); |
| 82 | } |
| 83 | |
| 84 | /** |
| 85 | * Show a setup dialog wrapped in AppStateProvider + KeybindingSetup. |
no test coverage detected