File tree Expand file tree Collapse file tree 2 files changed +21
-0
lines changed Expand file tree Collapse file tree 2 files changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -44,6 +44,7 @@ RouteConfiguration buildRouteConfiguration(Directory directory) {
44
44
onRogueRoute: rogueRoutes.add,
45
45
);
46
46
final publicDirectory = Directory (path.join (directory.path, 'public' ));
47
+ final mainDartFile = File (path.join (directory.path, 'main.dart' ));
47
48
return RouteConfiguration (
48
49
globalMiddleware: globalMiddleware,
49
50
middleware: middleware,
@@ -52,6 +53,7 @@ RouteConfiguration buildRouteConfiguration(Directory directory) {
52
53
rogueRoutes: rogueRoutes,
53
54
endpoints: endpoints,
54
55
serveStaticFiles: publicDirectory.existsSync (),
56
+ invokeCustomEntrypoint: mainDartFile.existsSync (),
55
57
);
56
58
}
57
59
@@ -285,8 +287,12 @@ class RouteConfiguration {
285
287
required this .endpoints,
286
288
required this .rogueRoutes,
287
289
this .serveStaticFiles = false ,
290
+ this .invokeCustomEntrypoint = false ,
288
291
});
289
292
293
+ /// Whether to invoke a custom entrypoint script (`main.dart` ).
294
+ final bool invokeCustomEntrypoint;
295
+
290
296
/// Whether to serve static files. Defaults to false.
291
297
final bool serveStaticFiles;
292
298
Original file line number Diff line number Diff line change @@ -40,6 +40,21 @@ void main() {
40
40
expect (configuration.serveStaticFiles, isFalse);
41
41
});
42
42
43
+ test ('invokeCustomEntrypoint is true when main.dart exists' , () {
44
+ final directory = Directory .systemTemp.createTempSync ();
45
+ Directory (path.join (directory.path, 'routes' )).createSync ();
46
+ File (path.join (directory.path, 'main.dart' )).createSync ();
47
+ final configuration = buildRouteConfiguration (directory);
48
+ expect (configuration.invokeCustomEntrypoint, isTrue);
49
+ });
50
+
51
+ test ('invokeCustomEntrypoint is false when main.dart does not exist' , () {
52
+ final directory = Directory .systemTemp.createTempSync ();
53
+ Directory (path.join (directory.path, 'routes' )).createSync ();
54
+ final configuration = buildRouteConfiguration (directory);
55
+ expect (configuration.invokeCustomEntrypoint, isFalse);
56
+ });
57
+
43
58
test ('includes global middleware when it exists' , () {
44
59
final directory = Directory .systemTemp.createTempSync ();
45
60
final routes = Directory (path.join (directory.path, 'routes' ))
You can’t perform that action at this time.
0 commit comments