From 898790d88adf3e1dcab3c50f3fafc88ddb6eef7c Mon Sep 17 00:00:00 2001 From: Chris Trinh Date: Tue, 8 Aug 2017 06:41:14 -0700 Subject: [PATCH] add --port options to run-android, defaults to 8081 Summary: Closes https://github.com/facebook/react-native/pull/15316 Differential Revision: D5582599 Pulled By: javache fbshipit-source-id: 575e0540965792a25e6cc572cff103da2c65a262 --- local-cli/runAndroid/runAndroid.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/local-cli/runAndroid/runAndroid.js b/local-cli/runAndroid/runAndroid.js index 14ea61caef9d78..a2626cd9b3f7bf 100644 --- a/local-cli/runAndroid/runAndroid.js +++ b/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), }], };