( options: BaseListOptions, hostOptions: ListHostOptions, fn: (host: ExtensionHost) => Promise<T>, )
| 231 | } |
| 232 | |
| 233 | async function withHostAndSignalHandlers<T>( |
| 234 | options: BaseListOptions, |
| 235 | hostOptions: ListHostOptions, |
| 236 | fn: (host: ExtensionHost) => Promise<T>, |
| 237 | ): Promise<T> { |
| 238 | const host = await createListHost(options, hostOptions) |
| 239 | |
| 240 | const shutdown = async (exitCode: number) => { |
| 241 | await host.dispose() |
| 242 | process.exit(exitCode) |
| 243 | } |
| 244 | |
| 245 | const onSigint = () => void shutdown(130) |
| 246 | const onSigterm = () => void shutdown(143) |
| 247 | |
| 248 | process.on("SIGINT", onSigint) |
| 249 | process.on("SIGTERM", onSigterm) |
| 250 | |
| 251 | try { |
| 252 | return await fn(host) |
| 253 | } finally { |
| 254 | process.off("SIGINT", onSigint) |
| 255 | process.off("SIGTERM", onSigterm) |
| 256 | await host.dispose() |
| 257 | } |
| 258 | } |
| 259 | |
| 260 | export async function listCommands(options: BaseListOptions): Promise<void> { |
| 261 | const format = parseFormat(options.format) |
no test coverage detected