Skip to content

Commit c8840cf

Browse files
committed
reuse startDevServer
1 parent 2d06f60 commit c8840cf

File tree

2 files changed

+15
-40
lines changed

2 files changed

+15
-40
lines changed

packages/plugin-metro/src/lib/start/command.ts

Lines changed: 7 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -39,28 +39,13 @@ export const registerStartCommand = (api: PluginApi) => {
3939
name: 'start',
4040
action: async (args: StartCommandArgs) => {
4141
intro('Starting Metro dev server');
42-
const root = api.getProjectRoot();
43-
const { port, startDevServer } = await findDevServerPort(
44-
args.port ? Number(args.port) : 8081,
45-
root,
46-
);
47-
48-
if (!startDevServer) {
49-
return;
50-
}
51-
52-
const reactNativeVersion = api.getReactNativeVersion();
53-
const reactNativePath = api.getReactNativePath();
54-
const platforms = api.getPlatforms();
55-
return runServer(
56-
{
57-
root,
58-
reactNativeVersion,
59-
reactNativePath,
60-
platforms,
61-
},
62-
{ ...args, port },
63-
);
42+
startDevServer({
43+
root: api.getProjectRoot(),
44+
reactNativeVersion: api.getReactNativeVersion(),
45+
reactNativePath: api.getReactNativePath(),
46+
platforms: api.getPlatforms(),
47+
args,
48+
});
6449
},
6550
description: 'Start the Metro development server.',
6651
options: [

packages/plugin-repack/src/lib/pluginRepack.ts

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -77,24 +77,14 @@ export const pluginRepack =
7777
name: 'start',
7878
description: 'Starts Re.Pack dev server.',
7979
action: async (args: StartArgs) => {
80-
const reactNativePath = api.getReactNativePath();
81-
const root = api.getProjectRoot();
82-
const platforms = api.getPlatforms();
83-
const { port, startDevServer } = await findDevServerPort(
84-
args.port ? Number(args.port) : 8081,
85-
root,
86-
);
87-
88-
if (!startDevServer) {
89-
return;
90-
}
91-
92-
startCommand.func(
93-
[],
94-
// @ts-expect-error TODO fix getPlatforms type
95-
{ reactNativePath, root, platforms, ...pluginConfig },
96-
{ ...args, port },
97-
);
80+
startDevServer({
81+
root: api.getProjectRoot(),
82+
reactNativeVersion: api.getReactNativeVersion(),
83+
reactNativePath: api.getReactNativePath(),
84+
platforms: api.getPlatforms(),
85+
// @ts-expect-error Re.Pack doesn't have clientLogs
86+
args,
87+
});
9888
},
9989
// @ts-expect-error fixup types
10090
options: startCommand.options,

0 commit comments

Comments
 (0)