@@ -23,17 +23,20 @@ const dir = args.directory || '.';
2323
2424const log = function ( request , response , statusCode ) {
2525 const d = new Date ( ) ;
26+ /* c8 ignore next 3 -- Time-dependent */
2627 const seconds = d . getSeconds ( ) < 10 ? '0' + d . getSeconds ( ) : d . getSeconds ( ) ,
2728 minutes = d . getMinutes ( ) < 10 ? '0' + d . getMinutes ( ) : d . getMinutes ( ) ,
2829 hours = d . getHours ( ) < 10 ? '0' + d . getHours ( ) : d . getHours ( ) ,
2930 datestr = hours + ':' + minutes + ':' + seconds ,
3031
3132 line = datestr + ' [' + response . statusCode + ']: ' + request . url ;
3233 let colorized = line ;
33- if ( tty . isatty ( process . stdout . fd ) )
34+ /* c8 ignore next 5 -- Environment */
35+ if ( tty . isatty ( process . stdout . fd ) ) {
3436 colorized = ( response . statusCode >= 500 ) ? colors . red . bold ( line ) :
3537 ( response . statusCode >= 400 ) ? colors . red ( line ) :
3638 line ;
39+ }
3740 console . log ( colorized ) ;
3841} ;
3942
@@ -77,7 +80,7 @@ const server = http.createServer(function (request, response) {
7780 // npm start -- --spa --index-file test/fixtures/there/index.html
7881 // with http://127.0.0.1:8080/test/fixtures/there?email=john.cena
7982 if ( args [ 'spa' ] && ! new URL ( request . url , 'http://localhost' ) . pathname . includes ( "." ) ) {
80- file . serveFile ( args [ 'index-file' ] , 200 , { } , request , response ) ;
83+ file . serveFile ( args [ 'index-file' ] || 'index.html' , 200 , { } , request , response ) ;
8184 } else {
8285 file . serve ( request , response , callback ) ;
8386 }
@@ -89,6 +92,7 @@ const hostAddress = args['host-address'] || '127.0.0.1';
8992
9093if ( hostAddress === '127.0.0.1' ) {
9194 server . listen ( port ) ;
95+ /* c8 ignore next 3 -- Not working with localhost or 0.0.0.0 */
9296} else {
9397 server . listen ( port , hostAddress ) ;
9498}
0 commit comments