Skip to content

Commit

Permalink
feat(dart_frog_dev): add host option to dart frog dev
Browse files Browse the repository at this point in the history
  • Loading branch information
renancaraujo committed Oct 17, 2023
1 parent 7b67791 commit 1b38183
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 2 deletions.
4 changes: 2 additions & 2 deletions bricks/dart_frog_dev_server/__brick__/server.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions bricks/dart_frog_dev_server/hooks/pre_gen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ Future<void> preGen(
);

context.vars = {
'host': context.vars['host'] ?? '',
'port': context.vars['port'] ?? '8080',
'directories': configuration.directories
.map((c) => c.toJson())
Expand Down
40 changes: 40 additions & 0 deletions bricks/dart_frog_dev_server/hooks/test/pre_gen_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,43 @@ void main() {
equals(
{
'port': customPort,
'host': '',
'directories': <RouteDirectory>[],
'routes': <RouteFile>[],
'middleware': <MiddlewareFile>[],
'globalMiddleware': false,
'serveStaticFiles': false,
'invokeCustomEntrypoint': false,
'invokeCustomInit': false,
},
),
);
});

test('retains custom host if specified', () async {
const customHost = '192.168.1.2';
context.vars['host'] = customHost;
const configuration = RouteConfiguration(
middleware: [],
directories: [],
routes: [],
rogueRoutes: [],
endpoints: {},
);
final exitCalls = <int>[];
await preGen(
context,
buildConfiguration: (_) => configuration,
exit: exitCalls.add,
);
expect(exitCalls, isEmpty);
verifyNever(() => logger.err(any()));
expect(
context.vars,
equals(
{
'port': '8080',
'host': '192.168.1.2',
'directories': <RouteDirectory>[],
'routes': <RouteFile>[],
'middleware': <MiddlewareFile>[],
Expand Down Expand Up @@ -198,6 +235,7 @@ void main() {
equals(
{
'port': customPort,
'host': '',
'directories': <RouteDirectory>[],
'routes': <RouteFile>[],
'middleware': <MiddlewareFile>[],
Expand Down Expand Up @@ -234,6 +272,7 @@ void main() {
equals(
{
'port': customPort,
'host': '',
'directories': <RouteDirectory>[],
'routes': <RouteFile>[],
'middleware': <MiddlewareFile>[],
Expand Down Expand Up @@ -335,6 +374,7 @@ void main() {
equals(
{
'port': '8080',
'host': '',
'directories': [
{
'name': '_',
Expand Down

0 comments on commit 1b38183

Please sign in to comment.