(opts: CLIOptions)
| 167 | } |
| 168 | |
| 169 | async function runHandleMainCommand(opts: CLIOptions): Promise<number | null> { |
| 170 | const exitSpy = vi.spyOn(process, 'exit').mockImplementation((code?: string | number | null) => { |
| 171 | throw new ExitCalled(Number(code ?? 0)); |
| 172 | }); |
| 173 | try { |
| 174 | await handleMainCommand(opts, '0.0.1-alpha.2'); |
| 175 | return null; |
| 176 | } catch (error) { |
| 177 | if (error instanceof ExitCalled) { |
| 178 | return error.code; |
| 179 | } |
| 180 | throw error; |
| 181 | } finally { |
| 182 | exitSpy.mockRestore(); |
| 183 | } |
| 184 | } |
| 185 | |
| 186 | async function runHandleUpgradeCommand(): Promise<number> { |
| 187 | const exitSpy = vi.spyOn(process, 'exit').mockImplementation((code?: string | number | null) => { |
no test coverage detected