mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
chore(dev-middleware): add localhost as default host in start command config (#44244)
Summary: Inside [Re.Pack](https://github.com/callstack/repack) we consume command's options, to reduce the amount of assumptions that 3rd party tools need to make - we can move assigning default value to config command level, so default values will be aligned across tools. For default `start` command this change doesn't change any behaviour. ## Changelog: [INTERNAL] [CHANGED] - Add `localhost` as default host in `start` command config Pull Request resolved: https://github.com/facebook/react-native/pull/44244 Test Plan: `start` command should work the same way as before. Reviewed By: huntie Differential Revision: D56567793 Pulled By: blakef fbshipit-source-id: fe8f3686ae39a3d2996de11930a0d03364692adc
This commit is contained in:
committed by
Facebook GitHub Bot
parent
78ab5f4b83
commit
c402dcfe57
@@ -27,7 +27,7 @@ const startCommand: Command = {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: '--host <string>',
|
name: '--host <string>',
|
||||||
default: '',
|
default: 'localhost',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: '--projectRoot <path>',
|
name: '--projectRoot <path>',
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ export type StartCommandArgs = {
|
|||||||
cert?: string,
|
cert?: string,
|
||||||
customLogReporterPath?: string,
|
customLogReporterPath?: string,
|
||||||
experimentalDebugger: boolean,
|
experimentalDebugger: boolean,
|
||||||
host?: string,
|
host: string,
|
||||||
https?: boolean,
|
https?: boolean,
|
||||||
maxWorkers?: number,
|
maxWorkers?: number,
|
||||||
key?: string,
|
key?: string,
|
||||||
@@ -63,14 +63,13 @@ async function runServer(
|
|||||||
projectRoot: args.projectRoot,
|
projectRoot: args.projectRoot,
|
||||||
sourceExts: args.sourceExts,
|
sourceExts: args.sourceExts,
|
||||||
});
|
});
|
||||||
const hostname = args.host?.length ? args.host : 'localhost';
|
|
||||||
const {
|
const {
|
||||||
projectRoot,
|
projectRoot,
|
||||||
server: {port},
|
server: {port},
|
||||||
watchFolders,
|
watchFolders,
|
||||||
} = metroConfig;
|
} = metroConfig;
|
||||||
const protocol = args.https === true ? 'https' : 'http';
|
const protocol = args.https === true ? 'https' : 'http';
|
||||||
const devServerUrl = url.format({protocol, hostname, port});
|
const devServerUrl = url.format({protocol, hostname: args.host, port});
|
||||||
|
|
||||||
logger.info(`Welcome to React Native v${ctx.reactNativeVersion}`);
|
logger.info(`Welcome to React Native v${ctx.reactNativeVersion}`);
|
||||||
|
|
||||||
@@ -104,7 +103,7 @@ async function runServer(
|
|||||||
messageSocketEndpoint,
|
messageSocketEndpoint,
|
||||||
eventsSocketEndpoint,
|
eventsSocketEndpoint,
|
||||||
} = createDevServerMiddleware({
|
} = createDevServerMiddleware({
|
||||||
host: hostname,
|
host: args.host,
|
||||||
port,
|
port,
|
||||||
watchFolders,
|
watchFolders,
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user