@@ -6,7 +6,6 @@ import connect from 'connect';
66import nocache from 'nocache' ;
77import { isPortAvailable , getMetroPackage } from './utils.js' ;
88import { MetroPortUnavailableError } from './errors.js' ;
9- import { METRO_PORT } from './constants.js' ;
109import type { MetroInstance , MetroOptions } from './types.js' ;
1110import {
1211 type Reporter ,
@@ -41,18 +40,19 @@ export const getMetroInstance = async (
4140 abortSignal : AbortSignal
4241) : Promise < MetroInstance > => {
4342 const { projectRoot, harnessConfig } = options ;
44- const isDefaultPortAvailable = await isPortAvailable ( METRO_PORT ) ;
43+ const metroPort = harnessConfig . metroPort ;
44+ const isMetroPortAvailable = await isPortAvailable ( metroPort ) ;
4545
46- if ( ! isDefaultPortAvailable ) {
47- throw new MetroPortUnavailableError ( METRO_PORT ) ;
46+ if ( ! isMetroPortAvailable ) {
47+ throw new MetroPortUnavailableError ( metroPort ) ;
4848 }
4949
5050 const Metro = getMetroPackage ( projectRoot ) ;
5151
5252 process . env . RN_HARNESS = 'true' ;
5353
5454 const projectMetroConfig = await Metro . loadConfig ( {
55- port : METRO_PORT ,
55+ port : metroPort ,
5656 projectRoot,
5757 } ) ;
5858 const config = await withRnHarness ( projectMetroConfig , true ) ( ) ;
@@ -62,7 +62,7 @@ export const getMetroInstance = async (
6262
6363 const middleware = connect ( )
6464 . use ( nocache ( ) )
65- . use ( '/' , getExpoMiddleware ( projectRoot , harnessConfig . entryPoint ) )
65+ . use ( '/' , getExpoMiddleware ( projectRoot , harnessConfig . entryPoint , metroPort ) )
6666 . use ( '/status' , getStatusMiddleware ( projectRoot ) ) ;
6767
6868 const ready = waitForBundler ( reporter , abortSignal ) ;
0 commit comments