MCPcopy
hub / github.com/facebook/react / subscribeKeyEvents

Function subscribeKeyEvents

compiler/packages/snap/src/runner-watch.ts:198–218  ·  view source on GitHub ↗
(
  state: RunnerState,
  onChange: (state: RunnerState) => void,
)

Source from the content-addressed store, hash-verified

196}
197
198function 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
220export async function makeWatchRunner(
221 onChange: (state: RunnerState) => void,

Callers 1

makeWatchRunnerFunction · 0.85

Calls 4

readTestFilterFunction · 0.90
onMethod · 0.80
exitMethod · 0.80
onChangeFunction · 0.70

Tested by

no test coverage detected