Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix start command exit behaviour #39788

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,18 @@ import {logger} from '@react-native-community/cli-tools';
import chalk from 'chalk';
import execa from 'execa';
import fetch from 'node-fetch';
import readline from 'readline';
import {KeyPressHandler} from '../../utils/KeyPressHandler';

const CTRL_C = '\u0003';
const CTRL_D = '\u0004';

export default function attachKeyHandlers({
cliConfig,
serverInstance,
devServerUrl,
messageSocket,
}: {
cliConfig: Config,
devServerUrl: string,
serverInstance: http$Server | https$Server,
messageSocket: $ReadOnly<{
broadcast: (type: string, params?: Record<string, mixed> | null) => void,
...
Expand All @@ -40,10 +37,6 @@ export default function attachKeyHandlers({
return;
}

readline.emitKeypressEvents(process.stdin);
// $FlowIgnore[prop-missing]
process.stdin.setRawMode(true);

const execaOptions = {
env: {FORCE_COLOR: chalk.supportsColor ? 'true' : 'false'},
};
Expand Down Expand Up @@ -88,16 +81,14 @@ export default function attachKeyHandlers({
case CTRL_C:
case CTRL_D:
logger.info('Stopping server');
listener?.({pause: true});
serverInstance.close(() => {
process.emit('SIGINT');
process.exit();
});
keyPressHandler.stopInterceptingKeyStrokes();
process.emit('SIGINT');
process.exit();
}
};

const keyPressHandler = new KeyPressHandler(onPress);
const listener = keyPressHandler.createInteractionListener();
keyPressHandler.createInteractionListener();
keyPressHandler.startInterceptingKeyStrokes();

logger.log(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,6 @@ async function runServer(
attachKeyHandlers({
cliConfig: ctx,
devServerUrl,
serverInstance,
messageSocket: messageSocketEndpoint,
});
}
Expand Down