@@ -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
179179function 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