(params: {
hookId: string
hookName: string
hookEvent: string
getOutput: () => Promise<{ stdout: string; stderr: string; output: string }>
intervalMs?: number
})
| 122 | } |
| 123 | |
| 124 | export function startHookProgressInterval(params: { |
| 125 | hookId: string |
| 126 | hookName: string |
| 127 | hookEvent: string |
| 128 | getOutput: () => Promise<{ stdout: string; stderr: string; output: string }> |
| 129 | intervalMs?: number |
| 130 | }): () => void { |
| 131 | if (!shouldEmit(params.hookEvent)) return () => {} |
| 132 | |
| 133 | let lastEmittedOutput = '' |
| 134 | const interval = setInterval(() => { |
| 135 | void params.getOutput().then(({ stdout, stderr, output }) => { |
| 136 | if (output === lastEmittedOutput) return |
| 137 | lastEmittedOutput = output |
| 138 | emitHookProgress({ |
| 139 | hookId: params.hookId, |
| 140 | hookName: params.hookName, |
| 141 | hookEvent: params.hookEvent, |
| 142 | stdout, |
| 143 | stderr, |
| 144 | output, |
| 145 | }) |
| 146 | }) |
| 147 | }, params.intervalMs ?? 1000) |
| 148 | interval.unref() |
| 149 | |
| 150 | return () => clearInterval(interval) |
| 151 | } |
| 152 | |
| 153 | export function emitHookResponse(data: { |
| 154 | hookId: string |
no test coverage detected