@@ -66,10 +66,10 @@ function getAdbPath() {
66
66
}
67
67
68
68
// Runs ADB reverse tcp:8081 tcp:8081 to allow loading the jsbundle from the packager
69
- function tryRunAdbReverse ( device ) {
69
+ function tryRunAdbReverse ( packagerPort , device ) {
70
70
try {
71
71
const adbPath = getAdbPath ( ) ;
72
- const adbArgs = [ 'reverse' , ' tcp:8081' , ' tcp:8081' ] ;
72
+ const adbArgs = [ 'reverse' , ` tcp:${ packagerPort } ` , ` tcp:${ packagerPort } ` ] ;
73
73
74
74
// If a device is specified then tell adb to use it
75
75
if ( device ) {
@@ -177,7 +177,7 @@ function tryLaunchAppOnDevice(device, packageNameWithSuffix, packageName, adbPat
177
177
}
178
178
179
179
function installAndLaunchOnDevice ( args , selectedDevice , packageNameWithSuffix , packageName , adbPath ) {
180
- tryRunAdbReverse ( selectedDevice ) ;
180
+ tryRunAdbReverse ( args . port , selectedDevice ) ;
181
181
tryInstallAppOnDevice ( args , selectedDevice ) ;
182
182
tryLaunchAppOnDevice ( selectedDevice , packageNameWithSuffix , packageName , adbPath , args . mainActivity ) ;
183
183
}
@@ -226,7 +226,7 @@ function runOnAllDevices(args, cmd, packageNameWithSuffix, packageName, adbPath)
226
226
const devices = adb . getDevices ( ) ;
227
227
if ( devices && devices . length > 0 ) {
228
228
devices . forEach ( ( device ) => {
229
- tryRunAdbReverse ( device ) ;
229
+ tryRunAdbReverse ( args . port , device ) ;
230
230
tryLaunchAppOnDevice ( device , packageNameWithSuffix , packageName , adbPath , args . mainActivity ) ;
231
231
} ) ;
232
232
} else {
@@ -317,5 +317,9 @@ module.exports = {
317
317
} , {
318
318
command : '--no-packager' ,
319
319
description : 'Do not launch packager while building' ,
320
+ } , {
321
+ command : '--port [number]' ,
322
+ default : 8081 ,
323
+ parse : ( val : string ) => Number ( val ) ,
320
324
} ] ,
321
325
} ;
0 commit comments