Permalink
Browse files

add --port options to run-android, defaults to 8081

Summary: Closes #15316

Differential Revision: D5582599

Pulled By: javache

fbshipit-source-id: 575e0540965792a25e6cc572cff103da2c65a262
  • Loading branch information...
Chris Trinh authored and facebook-github-bot committed Aug 8, 2017
1 parent 66a788f commit 898790d88adf3e1dcab3c50f3fafc88ddb6eef7c
Showing with 8 additions and 4 deletions.
  1. +8 −4 local-cli/runAndroid/runAndroid.js
@@ -66,10 +66,10 @@ function getAdbPath() {
}
// Runs ADB reverse tcp:8081 tcp:8081 to allow loading the jsbundle from the packager
function tryRunAdbReverse(device) {
function tryRunAdbReverse(packagerPort, device) {
try {
const adbPath = getAdbPath();
const adbArgs = ['reverse', 'tcp:8081', 'tcp:8081'];
const adbArgs = ['reverse', `tcp:${packagerPort}`, `tcp:${packagerPort}`];
// If a device is specified then tell adb to use it
if (device) {
@@ -177,7 +177,7 @@ function tryLaunchAppOnDevice(device, packageNameWithSuffix, packageName, adbPat
}
function installAndLaunchOnDevice(args, selectedDevice, packageNameWithSuffix, packageName, adbPath) {
tryRunAdbReverse(selectedDevice);
tryRunAdbReverse(args.port, selectedDevice);
tryInstallAppOnDevice(args, selectedDevice);
tryLaunchAppOnDevice(selectedDevice, packageNameWithSuffix, packageName, adbPath, args.mainActivity);
}
@@ -226,7 +226,7 @@ function runOnAllDevices(args, cmd, packageNameWithSuffix, packageName, adbPath)
const devices = adb.getDevices();
if (devices && devices.length > 0) {
devices.forEach((device) => {
tryRunAdbReverse(device);
tryRunAdbReverse(args.port, device);
tryLaunchAppOnDevice(device, packageNameWithSuffix, packageName, adbPath, args.mainActivity);
});
} else {
@@ -317,5 +317,9 @@ module.exports = {
}, {
command: '--no-packager',
description: 'Do not launch packager while building',
}, {
command: '--port [number]',
default: 8081,
parse: (val: string) => Number(val),
}],
};

0 comments on commit 898790d

Please sign in to comment.