Skip to content

Commit 898790d

Browse files
Chris Trinhfacebook-github-bot
Chris Trinh
authored andcommitted
add --port options to run-android, defaults to 8081
Summary: Closes #15316 Differential Revision: D5582599 Pulled By: javache fbshipit-source-id: 575e0540965792a25e6cc572cff103da2c65a262
1 parent 66a788f commit 898790d

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

local-cli/runAndroid/runAndroid.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,10 @@ function getAdbPath() {
6666
}
6767

6868
// Runs ADB reverse tcp:8081 tcp:8081 to allow loading the jsbundle from the packager
69-
function tryRunAdbReverse(device) {
69+
function tryRunAdbReverse(packagerPort, device) {
7070
try {
7171
const adbPath = getAdbPath();
72-
const adbArgs = ['reverse', 'tcp:8081', 'tcp:8081'];
72+
const adbArgs = ['reverse', `tcp:${packagerPort}`, `tcp:${packagerPort}`];
7373

7474
// If a device is specified then tell adb to use it
7575
if (device) {
@@ -177,7 +177,7 @@ function tryLaunchAppOnDevice(device, packageNameWithSuffix, packageName, adbPat
177177
}
178178

179179
function installAndLaunchOnDevice(args, selectedDevice, packageNameWithSuffix, packageName, adbPath) {
180-
tryRunAdbReverse(selectedDevice);
180+
tryRunAdbReverse(args.port, selectedDevice);
181181
tryInstallAppOnDevice(args, selectedDevice);
182182
tryLaunchAppOnDevice(selectedDevice, packageNameWithSuffix, packageName, adbPath, args.mainActivity);
183183
}
@@ -226,7 +226,7 @@ function runOnAllDevices(args, cmd, packageNameWithSuffix, packageName, adbPath)
226226
const devices = adb.getDevices();
227227
if (devices && devices.length > 0) {
228228
devices.forEach((device) => {
229-
tryRunAdbReverse(device);
229+
tryRunAdbReverse(args.port, device);
230230
tryLaunchAppOnDevice(device, packageNameWithSuffix, packageName, adbPath, args.mainActivity);
231231
});
232232
} else {
@@ -317,5 +317,9 @@ module.exports = {
317317
}, {
318318
command: '--no-packager',
319319
description: 'Do not launch packager while building',
320+
}, {
321+
command: '--port [number]',
322+
default: 8081,
323+
parse: (val: string) => Number(val),
320324
}],
321325
};

0 commit comments

Comments
 (0)