(
runtime: { error: (message: string) => void; exit: (code: number) => void },
action: () => Promise<void>,
onError?: (error: unknown) => void,
)
| 32 | } |
| 33 | |
| 34 | export async function runCommandWithRuntime( |
| 35 | runtime: { error: (message: string) => void; exit: (code: number) => void }, |
| 36 | action: () => Promise<void>, |
| 37 | onError?: (error: unknown) => void, |
| 38 | ): Promise<void> { |
| 39 | try { |
| 40 | await action(); |
| 41 | } catch (err) { |
| 42 | if (onError) { |
| 43 | onError(err); |
| 44 | return; |
| 45 | } |
| 46 | runtime.error(String(err)); |
| 47 | runtime.exit(1); |
| 48 | } |
| 49 | } |
| 50 | |
| 51 | export function resolveOptionFromCommand<T>( |
| 52 | command: Command | undefined, |
no test coverage detected