}
let activeClient: undefined | WebSocketClient
-let activeSpinner: ReturnType<typeof ora> | undefined
+let activeSpinner: null | ReturnType<typeof ora> | undefined
let cleanupInProgress = false
export interface ExecuteOptions {
? ora({ stream: process.stderr }).start(`Connecting to ${url}`)
: null
- activeSpinner = spinner ?? undefined
+ activeSpinner = spinner
activeClient = client
const budget = timeoutMs ?? UI_WEBSOCKET_REQUEST_TIMEOUT_MS
import process from 'node:process'
import { type ResponsePayload, ResponseStatus } from 'ui-common'
+const hashIdTable = (ids: string[]) => {
+ const table = new Table({ head: [chalk.white('Hash ID')] })
+ for (const id of ids) {
+ table.push([id])
+ }
+ return table
+}
+
export const outputTable = (payload: ResponsePayload): void => {
if (payload.hashIdsSucceeded != null && payload.hashIdsSucceeded.length > 0) {
process.stdout.write(chalk.green(`✓ Succeeded (${String(payload.hashIdsSucceeded.length)}):\n`))
- const table = new Table({ head: [chalk.white('Hash ID')] })
- for (const id of payload.hashIdsSucceeded) {
- table.push([id])
- }
+ const table = hashIdTable(payload.hashIdsSucceeded)
process.stdout.write(table.toString() + '\n')
}
}
process.stderr.write(table.toString() + '\n')
} else {
- const table = new Table({ head: [chalk.white('Hash ID')] })
- for (const id of payload.hashIdsFailed) {
- table.push([id])
- }
+ const table = hashIdTable(payload.hashIdsFailed)
process.stderr.write(table.toString() + '\n')
}
}
const adapter = createWsAdapter(mockWs as unknown as WebSocket)
- const callback = (event: { data: string }): undefined => {
- // eslint-disable-next-line no-void
- void event
- return undefined
- }
+ const callback = (event: { data: string }): undefined => undefined
adapter.onmessage = callback
assert.strictEqual(adapter.onmessage, callback)
const adapter = createWsAdapter(mockWs as unknown as WebSocket)
- const callback = (event: { error: unknown; message: string }): undefined => {
- // eslint-disable-next-line no-void
- void event
- return undefined
- }
+ const callback = (_event: { error: unknown; message: string }): undefined => undefined
adapter.onerror = callback
assert.strictEqual(adapter.onerror, callback)
const adapter = createWsAdapter(mockWs as unknown as WebSocket)
- const callback = (event: { code: number; reason: string }): undefined => {
- // eslint-disable-next-line no-void
- void event
- return undefined
- }
+ const callback = (_event: { code: number; reason: string }): undefined => undefined
adapter.onclose = callback
assert.strictEqual(adapter.onclose, callback)
(error: unknown) => {
assert.ok(error instanceof Error)
assert.ok(error.message.includes('Invalid timeout'))
+ assert.ok(error.message.includes('0ms'))
return true
}
)
(error: unknown) => {
assert.ok(error instanceof Error)
assert.ok(error.message.includes('Invalid timeout'))
+ assert.ok(error.message.includes('-1ms'))
return true
}
)