Skip to content

Commit c402dcf

Browse files
szymonrybczakfacebook-github-bot
authored andcommitted
chore(dev-middleware): add localhost as default host in start command config (facebook#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: facebook#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
1 parent 78ab5f4 commit c402dcf

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

packages/community-cli-plugin/src/commands/start/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ const startCommand: Command = {
2727
},
2828
{
2929
name: '--host <string>',
30-
default: '',
30+
default: 'localhost',
3131
},
3232
{
3333
name: '--projectRoot <path>',

packages/community-cli-plugin/src/commands/start/runServer.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export type StartCommandArgs = {
3434
cert?: string,
3535
customLogReporterPath?: string,
3636
experimentalDebugger: boolean,
37-
host?: string,
37+
host: string,
3838
https?: boolean,
3939
maxWorkers?: number,
4040
key?: string,
@@ -63,14 +63,13 @@ async function runServer(
6363
projectRoot: args.projectRoot,
6464
sourceExts: args.sourceExts,
6565
});
66-
const hostname = args.host?.length ? args.host : 'localhost';
6766
const {
6867
projectRoot,
6968
server: {port},
7069
watchFolders,
7170
} = metroConfig;
7271
const protocol = args.https === true ? 'https' : 'http';
73-
const devServerUrl = url.format({protocol, hostname, port});
72+
const devServerUrl = url.format({protocol, hostname: args.host, port});
7473

7574
logger.info(`Welcome to React Native v${ctx.reactNativeVersion}`);
7675

@@ -104,7 +103,7 @@ async function runServer(
104103
messageSocketEndpoint,
105104
eventsSocketEndpoint,
106105
} = createDevServerMiddleware({
107-
host: hostname,
106+
host: args.host,
108107
port,
109108
watchFolders,
110109
});

0 commit comments

Comments
 (0)