( state: RunnerState, onChange: (state: RunnerState) => void, )
| 196 | } |
| 197 | |
| 198 | function subscribeKeyEvents( |
| 199 | state: RunnerState, |
| 200 | onChange: (state: RunnerState) => void, |
| 201 | ) { |
| 202 | process.stdin.on('keypress', async (str, key) => { |
| 203 | if (key.name === 'u') { |
| 204 | // u => update fixtures |
| 205 | state.mode.action = RunnerAction.Update; |
| 206 | } else if (key.name === 'q') { |
| 207 | process.exit(0); |
| 208 | } else if (key.name === 'f') { |
| 209 | state.mode.filter = !state.mode.filter; |
| 210 | state.filter = state.mode.filter ? await readTestFilter() : null; |
| 211 | state.mode.action = RunnerAction.Test; |
| 212 | } else { |
| 213 | // any other key re-runs tests |
| 214 | state.mode.action = RunnerAction.Test; |
| 215 | } |
| 216 | onChange(state); |
| 217 | }); |
| 218 | } |
| 219 | |
| 220 | export async function makeWatchRunner( |
| 221 | onChange: (state: RunnerState) => void, |
no test coverage detected