Skip to content

Commit

Permalink
add --port options to run-android, defaults to 8081
Browse files Browse the repository at this point in the history
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 898790d
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions local-cli/runAndroid/runAndroid.js
Expand Up @@ -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) {
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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.