run-android Chose your Term for OSX, and Linux

Summary:Main goal is to get this passed for OSX. I assume this works for linux; please verify. Also if specs need to be added, please suggest
an implementation as there is no __test__ dir for andriod.

using yargs (already a dependency) to allow other terminals besides OSX crummy default terminal. Like (iterm) :)

main use case:

` react-native run-android --open iterm`

The nice thing about this in ITERM is it opens another tab by default which is way less intrusive then OSX default term.
Closes https://github.com/facebook/react-native/pull/5232

Differential Revision: D3011590

Pulled By: mkonicek

fb-gh-sync-id: 7e2a004b3018b4d70aafadf4e9be9682561d7919
shipit-source-id: 7e2a004b3018b4d70aafadf4e9be9682561d7919
This commit is contained in:
nmccready 2016-03-04 21:54:47 -08:00 committed by Facebook Github Bot 9
parent 46422ddd99
commit 970782d147

View File

@ -141,18 +141,24 @@ function buildAndRun(args, reject) {
} }
function startServerInNewWindow() { function startServerInNewWindow() {
var yargV = require('yargs').argv;
const launchPackagerScript = path.resolve( const launchPackagerScript = path.resolve(
__dirname, '..', '..', 'packager', 'launchPackager.command' __dirname, '..', '..', 'packager', 'launchPackager.command'
); );
if (process.platform === 'darwin') { if (process.platform === 'darwin') {
child_process.spawnSync('open', [launchPackagerScript]); if (yargV.open) {
return child_process.spawnSync('open', ['-a', yargV.open, launchPackagerScript]);
}
return child_process.spawnSync('open', [launchPackagerScript]);
} else if (process.platform === 'linux') { } else if (process.platform === 'linux') {
child_process.spawn( if (yargV.open){
'xterm', return child_process.spawn(yargV.open,['-e', 'sh', launchPackagerScript], {detached: true});
['-e', 'sh', launchPackagerScript], }
{detached: true} return child_process.spawn('xterm',['-e', 'sh', launchPackagerScript],{detached: true});
);
} else if (/^win/.test(process.platform)) { } else if (/^win/.test(process.platform)) {
console.log(chalk.yellow('Starting the packager in a new window ' + console.log(chalk.yellow('Starting the packager in a new window ' +
'is not supported on Windows yet.\nPlease start it manually using ' + 'is not supported on Windows yet.\nPlease start it manually using ' +