@@ -28,6 +28,7 @@ export type BuildConfig = 'Debug' | 'DebugBundle' | 'Release' | 'ReleaseBundle';
2828 * deploy-from-layout: Force deploy from layout, even in release builds
2929 * sln: String - Solution file to build
3030 * msbuildprops: String - Comma separated props to pass to msbuild, eg: prop1=value1,prop2=value2
31+ * port: Number - Port to use for the React Native packager
3132 * direct-debugging: Number - Enable direct debugging on specified port
3233 * no-telemetry: Boolean - Disables sending telemetry that allows analysis of usage and failures of the react-native-windows CLI
3334 */
@@ -52,6 +53,7 @@ export interface RunWindowsOptions {
5253 msbuildprops ?: string ;
5354 buildLogDirectory ?: string ;
5455 info ?: boolean ;
56+ port ?: number ;
5557 directDebugging ?: number ;
5658 telemetry ?: boolean ;
5759}
@@ -147,6 +149,12 @@ export const runWindowsOptions: CommandOption[] = [
147149 name : '--info' ,
148150 description : 'Dump environment information' ,
149151 } ,
152+ {
153+ name : '--port [number]' ,
154+ description : 'Port to use for the React Native packager' ,
155+ default : 8081 ,
156+ parse : parsePort ,
157+ } ,
150158 {
151159 name : '--direct-debugging [number]' ,
152160 description : 'Enable direct debugging on specified port' ,
@@ -171,13 +179,17 @@ function parseBuildArch(arg: string): BuildArch {
171179}
172180
173181function parseDirectDebuggingPort ( arg : string ) : number {
174- const num = parseInt ( arg , 10 ) ;
182+ return parsePort ( arg , '--direct-debugging' ) ;
183+ }
184+
185+ function parsePort ( arg : string , optionName = '--port' ) : number {
186+ const num = Number ( arg ) ;
175187
176188 if ( ! Number . isInteger ( num ) ) {
177- errorOut ( `Expected argument '--direct-debugging ' to be a number` ) ;
189+ errorOut ( `Expected argument '${ optionName } ' to be a number` ) ;
178190 }
179191 if ( num < 1024 || num >= 65535 ) {
180- errorOut ( 'Direct debugging port it out of range' ) ;
192+ errorOut ( ` ${ optionName } is out of range` ) ;
181193 }
182194
183195 return num ;
0 commit comments