diff --git a/local-cli/run-android.js b/local-cli/run-android.js index f5333cab3..26da1e1a4 100644 --- a/local-cli/run-android.js +++ b/local-cli/run-android.js @@ -31,9 +31,10 @@ function buildAndRun() { } try { var packageName = fs.readFileSync('app/src/main/AndroidManifest.xml', 'utf8').match(/package="(.+?)"/)[1]; + var adbPath = process.env.ANDROID_HOME ? process.env.ANDROID_HOME + '/platform-tools/adb' : 'adb'; var adbArgs = ['shell', 'am', 'start', '-n', packageName + '/.MainActivity']; - console.log(chalk.bold('Starting the app (adb ' + adbArgs.join(' ') + ')...')); - child_process.spawnSync('adb', adbArgs, { + console.log(chalk.bold('Starting the app (' + adbPath + ' ' + adbArgs.join(' ') + ')...')); + child_process.spawnSync(adbPath, adbArgs, { stdio: [process.stdin, process.stdout, process.stderr] }); } catch (e) { @@ -62,6 +63,8 @@ module.exports = function() { console.log(chalk.yellow('[warn] JS server not recognized, continuing with build...')); } buildAndRun(); + // make sure we don't wait around for the packager process + process.exit(); }); }); statusReq.on('error', function() { @@ -70,4 +73,4 @@ module.exports = function() { runPackager(true); buildAndRun(); }); -}; \ No newline at end of file +}; diff --git a/local-cli/run-packager.js b/local-cli/run-packager.js index 80b06f70e..111c15b02 100644 --- a/local-cli/run-packager.js +++ b/local-cli/run-packager.js @@ -5,9 +5,16 @@ var child_process = require('child_process'); module.exports = function(newWindow) { if (newWindow) { - child_process.spawnSync('open', [ - path.resolve(__dirname, '..', 'packager', 'launchPackager.command') - ]); + var launchPackagerScript = + path.resolve(__dirname, '..', 'packager', 'launchPackager.command'); + if (process.platform === 'darwin') { + child_process.spawnSync('open', [launchPackagerScript]); + } else if (process.platform === 'linux') { + child_process.spawn( + 'xterm', + ['-e', 'sh', launchPackagerScript], + {detached: true}); + } } else { child_process.spawn('sh', [ path.resolve(__dirname, '..', 'packager', 'packager.sh'), @@ -15,4 +22,4 @@ module.exports = function(newWindow) { process.cwd(), ], {stdio: 'inherit'}); } -}; \ No newline at end of file +};