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

[Linux/OSX] Add missing "--terminal" argument to run-android #20584

Closed
wants to merge 2 commits into from
Closed
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
15 changes: 11 additions & 4 deletions local-cli/runAndroid/runAndroid.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ function runAndroid(argv, config, args) {
} else {
// result == 'not_running'
console.log(chalk.bold('Starting JS server...'));
startServerInNewWindow(args.port);
startServerInNewWindow(args.port, args.terminal);
}
return buildAndRun(args);
});
Expand Down Expand Up @@ -348,7 +348,7 @@ function runOnAllDevices(
}
}

function startServerInNewWindow(port) {
function startServerInNewWindow(port, terminal = process.env.REACT_TERMINAL) {
// set up OS-specific filenames and commands
const isWindows = /^win/.test(process.platform);
const scriptFile = isWindows
Expand All @@ -363,7 +363,6 @@ function startServerInNewWindow(port) {
const scriptsDir = path.resolve(__dirname, '..', '..', 'scripts');
const launchPackagerScript = path.resolve(scriptsDir, scriptFile);
const procConfig = {cwd: scriptsDir};
const terminal = process.env.REACT_TERMINAL;

// set up the .packager.(env|bat) file to ensure the packager starts on the right port
const packagerEnvFile = path.join(
Expand All @@ -390,14 +389,16 @@ function startServerInNewWindow(port) {
}
return child_process.spawnSync('open', [launchPackagerScript], procConfig);
} else if (process.platform === 'linux') {
procConfig.detached = true;
if (terminal) {
procConfig.detached = true;
return child_process.spawn(
terminal,
['-e', 'sh ' + launchPackagerScript],
procConfig,
);
}
// By default, the child shell process will be attached to the parent
procConfig.detached = false;
return child_process.spawn('sh', [launchPackagerScript], procConfig);
} else if (/^win/.test(process.platform)) {
procConfig.detached = true;
Expand Down Expand Up @@ -474,5 +475,11 @@ module.exports = {
default: process.env.RCT_METRO_PORT || 8081,
parse: (val: string) => Number(val),
},
{
command: '--terminal [string]',
description:
'Launches the Metro Bundler in a new window using the specified terminal path.',
default: '',
},
],
};