@@ -132,7 +132,46 @@ namespace Moduless
132
132
if ( ! startingProject )
133
133
throw new Error ( "No projects found at location: " + target . projectPath ) ;
134
134
135
- startHttpServer ( graph . map ( entry => entry . project ) ) ;
135
+ target . functionNamespace + target . functionName
136
+
137
+ // Starts an HTTP server that serves the outFiles loaded
138
+ // from the discovered set of projects.
139
+ {
140
+ const projects = graph . map ( entry => entry . project )
141
+ const outFiles = projects . map ( p => p . outFile ) ;
142
+ let charIndex = 0 ;
143
+ for ( ; ; )
144
+ {
145
+ if ( outFiles . some ( f => f . length <= charIndex ) )
146
+ break ;
147
+
148
+ if ( ! outFiles . every ( f => f [ charIndex ] === outFiles [ 0 ] [ charIndex ] ) )
149
+ break ;
150
+
151
+ charIndex ++ ;
152
+ }
153
+
154
+ const path = outFiles [ 0 ] . slice ( 0 , charIndex ) ;
155
+ const runJs = target . functionNamespace + "." + target . functionName + "()" ;
156
+ const runScript = `<script>setTimeout(() => ${ runJs } )</script>` ;
157
+
158
+ Moduless . createServer ( {
159
+ path,
160
+ route : path =>
161
+ {
162
+ if ( path === "/" )
163
+ {
164
+ return [
165
+ "<!DOCTYPE html>" ,
166
+ ...outFiles . map ( f => `<script src="${ f . slice ( charIndex ) } "></script>` ) ,
167
+ runScript
168
+ ] . join ( "\n" ) ;
169
+ }
170
+ }
171
+ } ) ;
172
+
173
+ console . log ( "HTTP server is available at: http://localhost:" + Moduless . defaultHttpPort ) ;
174
+ }
136
175
137
176
const tryResolveNamepace = ( root : object ) =>
138
177
{
@@ -184,44 +223,6 @@ namespace Moduless
184
223
return true ;
185
224
}
186
225
187
- /**
188
- * Starts an HTTP server that serves the outFiles associated with the specified
189
- * list of projects.
190
- */
191
- function startHttpServer ( projects : Project [ ] )
192
- {
193
- const outFiles = projects . map ( p => p . outFile ) ;
194
- let charIndex = 0 ;
195
- for ( ; ; )
196
- {
197
- if ( outFiles . some ( f => f . length <= charIndex ) )
198
- break ;
199
-
200
- if ( ! outFiles . every ( f => f [ charIndex ] === outFiles [ 0 ] [ charIndex ] ) )
201
- break ;
202
-
203
- charIndex ++ ;
204
- }
205
-
206
- const path = outFiles [ 0 ] . slice ( 0 , charIndex ) ;
207
-
208
- Moduless . createServer ( {
209
- path,
210
- route : path =>
211
- {
212
- if ( path === "/" )
213
- {
214
- return [
215
- "<!DOCTYPE html>" ,
216
- ...outFiles . map ( f => `<script src="${ f . slice ( charIndex ) } "></script>` ) ,
217
- ] . join ( "\n" ) ;
218
- }
219
- }
220
- } ) ;
221
-
222
- console . log ( "HTTP server is available at: http://localhost:" + Moduless . defaultHttpPort ) ;
223
- }
224
-
225
226
/**
226
227
* Returns the name of the cover function currently being tested.
227
228
*/
0 commit comments