Skip to content

Commit a8a0e3a

Browse files
authored
feat(dart_frog_dev): add host option to dart frog dev (#1113)
1 parent 2c4901b commit a8a0e3a

File tree

3 files changed

+42
-1
lines changed

3 files changed

+42
-1
lines changed

bricks/dart_frog_dev_server/__brick__/server.dart

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bricks/dart_frog_dev_server/hooks/pre_gen.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ Future<void> preGen(
5656
);
5757

5858
context.vars = {
59+
'host': context.vars['host'] ?? '',
5960
'port': context.vars['port'] ?? '8080',
6061
'directories': configuration.directories
6162
.map((c) => c.toJson())

bricks/dart_frog_dev_server/hooks/test/pre_gen_test.dart

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,43 @@ void main() {
162162
equals(
163163
{
164164
'port': customPort,
165+
'host': '',
166+
'directories': <RouteDirectory>[],
167+
'routes': <RouteFile>[],
168+
'middleware': <MiddlewareFile>[],
169+
'globalMiddleware': false,
170+
'serveStaticFiles': false,
171+
'invokeCustomEntrypoint': false,
172+
'invokeCustomInit': false,
173+
},
174+
),
175+
);
176+
});
177+
178+
test('retains custom host if specified', () async {
179+
const customHost = '192.168.1.2';
180+
context.vars['host'] = customHost;
181+
const configuration = RouteConfiguration(
182+
middleware: [],
183+
directories: [],
184+
routes: [],
185+
rogueRoutes: [],
186+
endpoints: {},
187+
);
188+
final exitCalls = <int>[];
189+
await preGen(
190+
context,
191+
buildConfiguration: (_) => configuration,
192+
exit: exitCalls.add,
193+
);
194+
expect(exitCalls, isEmpty);
195+
verifyNever(() => logger.err(any()));
196+
expect(
197+
context.vars,
198+
equals(
199+
{
200+
'port': '8080',
201+
'host': '192.168.1.2',
165202
'directories': <RouteDirectory>[],
166203
'routes': <RouteFile>[],
167204
'middleware': <MiddlewareFile>[],
@@ -198,6 +235,7 @@ void main() {
198235
equals(
199236
{
200237
'port': customPort,
238+
'host': '',
201239
'directories': <RouteDirectory>[],
202240
'routes': <RouteFile>[],
203241
'middleware': <MiddlewareFile>[],
@@ -234,6 +272,7 @@ void main() {
234272
equals(
235273
{
236274
'port': customPort,
275+
'host': '',
237276
'directories': <RouteDirectory>[],
238277
'routes': <RouteFile>[],
239278
'middleware': <MiddlewareFile>[],
@@ -335,6 +374,7 @@ void main() {
335374
equals(
336375
{
337376
'port': '8080',
377+
'host': '',
338378
'directories': [
339379
{
340380
'name': '_',

0 commit comments

Comments
 (0)