Skip to content

Commit

Permalink
Fix for run-android on windows. (#2236)
Browse files Browse the repository at this point in the history
* Fix for `run-android` on windows.

* Comment added explaining why awaiting is not used

---------

Co-authored-by: Abdullah Al Jahid <jahid@chaldal.net>
  • Loading branch information
aajahid and Abdullah Al Jahid committed Dec 27, 2023
1 parent 933f6cf commit a36eefc
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ async function runAndroid(_argv: Array<string>, config: Config, args: Flags) {
);

if (startPackager) {
await startServerInNewWindow(
// Awaiting this causes the CLI to hang indefinitely, so this must execute without await.
startServerInNewWindow(
newPort,
config.root,
config.reactNativePath,
Expand Down
4 changes: 4 additions & 0 deletions packages/cli-tools/src/getDefaultUserTerminal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ const getDefaultUserTerminal = (): string | undefined => {
return TERM_PROGRAM;
}

if (os.platform() === 'win32') {
return 'cmd.exe';
}

return TERM;
};

Expand Down
2 changes: 1 addition & 1 deletion packages/cli-tools/src/startServerInNewWindow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ function startServerInNewWindow(
}
if (isWindows) {
// Awaiting this causes the CLI to hang indefinitely, so this must execute without await.
return execa('cmd.exe', ['/C', launchPackagerScript], {
return execa(terminal, ['/C', launchPackagerScript], {
...procConfig,
detached: true,
stdio: 'ignore',
Expand Down

0 comments on commit a36eefc

Please sign in to comment.