33 * Licensed under the MIT License. See License.txt in the project root for license information.
44 *--------------------------------------------------------------------------------------------*/
55
6- const express = require ( 'express' ) ;
6+ const yaserver = require ( 'yaserver' ) ;
7+ const http = require ( 'http' ) ;
78const glob = require ( 'glob' ) ;
89const path = require ( 'path' ) ;
910const fs = require ( 'fs' ) ;
@@ -17,32 +18,32 @@ function template(str, env) {
1718 } ) ;
1819}
1920
20- var app = express ( ) ;
21-
22- app . use ( '/out' , express . static ( path . join ( REPO_ROOT , 'out' ) ) ) ;
23- app . use ( '/ test' , express . static ( path . join ( REPO_ROOT , 'test' ) ) ) ;
24- app . use ( '/node_modules' , express . static ( path . join ( REPO_ROOT , 'node_modules' ) ) ) ;
25-
26- app . get ( '/' , function ( req , res ) {
27- glob ( '**/vs/{base,platform,editor}/**/test/{common,browser}/**/*.test.js' , {
28- cwd : path . join ( REPO_ROOT , 'out' ) ,
29- // ignore: ['**/test/{node,electron*}/**/*.js']
30- } , function ( err , files ) {
31- if ( err ) { return res . sendStatus ( 500 ) ; }
32-
33- var modules = files
34- . map ( function ( file ) { return file . replace ( / \. j s $ / , '' ) ; } ) ;
35-
36- fs . readFile ( path . join ( __dirname , 'index.html' ) , 'utf8' , function ( err , templateString ) {
37- if ( err ) { return res . sendStatus ( 500 ) ; }
38-
39- res . send ( template ( templateString , {
40- modules : JSON . stringify ( modules )
41- } ) ) ;
42- } ) ;
21+ yaserver . createServer ( { rootDir : REPO_ROOT } ) . then ( ( staticServer ) => {
22+ const server = http . createServer ( ( req , res ) => {
23+ if ( req . url === '' || req . url === '/' ) {
24+ glob ( '**/vs/{base,platform,editor}/**/ test/{common,browser}/**/*.test.js' , {
25+ cwd : path . join ( REPO_ROOT , 'out' ) ,
26+ // ignore: ['**/test/{node,electron*}/**/*.js']
27+ } , function ( err , files ) {
28+ if ( err ) { return res . sendStatus ( 500 ) ; }
29+
30+ var modules = files
31+ . map ( function ( file ) { return file . replace ( / \. j s $ / , '' ) ; } ) ;
32+
33+ fs . readFile ( path . join ( __dirname , 'index.html' ) , 'utf8' , function ( err , templateString ) {
34+ if ( err ) { return res . sendStatus ( 500 ) ; }
35+
36+ res . end ( template ( templateString , {
37+ modules : JSON . stringify ( modules )
38+ } ) ) ;
39+ } ) ;
40+ } ) ;
41+ } else {
42+ return staticServer . handle ( req , res ) ;
43+ }
4344 } ) ;
44- } ) ;
4545
46- app . listen ( PORT , function ( ) {
47- console . log ( 'http://localhost:8887/' ) ;
46+ server . listen ( PORT , ( ) => {
47+ console . log ( `http://localhost:${ PORT } /` ) ;
48+ } ) ;
4849} ) ;
0 commit comments