@@ -78,7 +78,7 @@ function runIOS(argv, config, args) {
78
78
function runOnDeviceByUdid ( args , scheme , xcodeProject , devices ) {
79
79
const selectedDevice = matchingDeviceByUdid ( devices , args . udid ) ;
80
80
if ( selectedDevice ) {
81
- return runOnDevice ( selectedDevice , scheme , xcodeProject , args . configuration , args . packager , args . verbose ) ;
81
+ return runOnDevice ( selectedDevice , scheme , xcodeProject , args . configuration , args . packager , args . verbose , args . port ) ;
82
82
} else {
83
83
if ( devices && devices . length > 0 ) {
84
84
console . log ( 'Could not find device with the udid: "' + args . udid + '".' ) ;
@@ -115,7 +115,7 @@ function runOnSimulator(xcodeProject, args, scheme) {
115
115
}
116
116
resolve ( selectedSimulator . udid ) ;
117
117
} )
118
- . then ( ( udid ) => buildProject ( xcodeProject , udid , scheme , args . configuration , args . packager , args . verbose ) )
118
+ . then ( ( udid ) => buildProject ( xcodeProject , udid , scheme , args . configuration , args . packager , args . verbose , args . port ) )
119
119
. then ( ( appName ) => {
120
120
if ( ! appName ) {
121
121
appName = scheme ;
@@ -135,8 +135,8 @@ function runOnSimulator(xcodeProject, args, scheme) {
135
135
} ) ;
136
136
}
137
137
138
- function runOnDevice ( selectedDevice , scheme , xcodeProject , configuration , launchPackager , verbose ) {
139
- return buildProject ( xcodeProject , selectedDevice . udid , scheme , configuration , launchPackager , verbose )
138
+ function runOnDevice ( selectedDevice , scheme , xcodeProject , configuration , launchPackager , verbose , port ) {
139
+ return buildProject ( xcodeProject , selectedDevice . udid , scheme , configuration , launchPackager , verbose , port )
140
140
. then ( ( appName ) => {
141
141
if ( ! appName ) {
142
142
appName = scheme ;
@@ -159,7 +159,7 @@ function runOnDevice(selectedDevice, scheme, xcodeProject, configuration, launch
159
159
} ) ;
160
160
}
161
161
162
- function buildProject ( xcodeProject , udid , scheme , configuration = 'Debug' , launchPackager = false , verbose ) {
162
+ function buildProject ( xcodeProject , udid , scheme , configuration = 'Debug' , launchPackager = false , verbose , port ) {
163
163
return new Promise ( ( resolve , reject ) =>
164
164
{
165
165
var xcodebuildArgs = [
@@ -174,7 +174,7 @@ function buildProject(xcodeProject, udid, scheme, configuration = 'Debug', launc
174
174
if ( ! verbose ) {
175
175
xcpretty = xcprettyAvailable ( ) && child_process . spawn ( 'xcpretty' , [ ] , { stdio : [ 'pipe' , process . stdout , process . stderr ] } ) ;
176
176
}
177
- const buildProcess = child_process . spawn ( 'xcodebuild' , xcodebuildArgs , getProcessOptions ( launchPackager ) ) ;
177
+ const buildProcess = child_process . spawn ( 'xcodebuild' , xcodebuildArgs , getProcessOptions ( launchPackager , port ) ) ;
178
178
let buildOutput = '' ;
179
179
buildProcess . stdout . on ( 'data' , function ( data ) {
180
180
buildOutput += data . toString ( ) ;
@@ -232,13 +232,15 @@ function printFoundDevices(devices) {
232
232
}
233
233
}
234
234
235
- function getProcessOptions ( launchPackager ) {
235
+ function getProcessOptions ( launchPackager , port ) {
236
236
if ( launchPackager ) {
237
- return { } ;
237
+ return {
238
+ env : { ...process . env , RCT_METRO_PORT : port }
239
+ } ;
238
240
}
239
241
240
242
return {
241
- env : Object . assign ( { } , process . env , { RCT_NO_LAUNCH_PACKAGER : true } ) ,
243
+ env : { ... process . env , RCT_NO_LAUNCH_PACKAGER : true } ,
242
244
} ;
243
245
}
244
246
@@ -287,5 +289,9 @@ module.exports = {
287
289
} , {
288
290
command : '--verbose' ,
289
291
description : 'Do not use xcpretty even if installed' ,
292
+ } , {
293
+ command : '--port [number]' ,
294
+ default : process . env . RCT_METRO_PORT || 8081 ,
295
+ parse : ( val : string ) => Number ( val ) ,
290
296
} ] ,
291
297
} ;
0 commit comments