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