1- module . exports = function ( grunt ) {
1+ 'use strict' ;
2+
3+ module . exports = function ( grunt ) {
24
35 function testResultLoggerMiddleware ( req , res , next ) {
4- if ( ! ( req . method == 'POST' && req . _parsedUrl . pathname . indexOf ( '/reportTestResults' ) === 0 ) ) return next ( ) ;
6+ if ( ! ( req . method == 'POST' && req . _parsedUrl . pathname . indexOf ( '/reportTestResults' ) === 0 ) ) {
7+ return next ( ) ;
8+ }
59 var logType = 'writeln' ;
610 var message = req . body ;
711
812 if ( req . body . type && req . body . message ) {
9- if ( req . body . type == 'error' ) logType = 'error' ;
10- else if ( req . body . message . indexOf ( 'ok' ) === 0 ) logType = 'ok' ;
11- else if ( req . body . message . indexOf ( 'not ok' ) === 0 ) logType = 'error' ;
13+ if ( req . body . type == 'error' ) {
14+ logType = 'error' ;
15+ } else if ( req . body . message . indexOf ( 'ok' ) === 0 ) {
16+ logType = 'ok' ;
17+ } else if ( req . body . message . indexOf ( 'not ok' ) === 0 ) {
18+ logType = 'error' ;
19+ }
1220 message = req . body . message ;
1321 }
14- if ( typeof message != 'string' ) message = JSON . stringify ( message , null , 2 ) ;
22+ if ( typeof message != 'string' ) {
23+ message = JSON . stringify ( message , null , 2 ) ;
24+ }
1525 grunt . log [ logType ] ( '[%s][%s]' , req . headers [ 'user-agent' ] , Date . now ( ) , message ) ;
1626 res . write ( '<!doctype html><meta charset=utf-8>' ) ;
1727 res . end ( 'Got it, thanks!' ) ;
@@ -24,20 +34,20 @@ module.exports = function(grunt){
2434 hostname : '*' ,
2535 port : 9999 ,
2636 middleware : function ( connect , options ) {
27-
28- connect . logger . token ( 'user-agent' , function ( req , res ) { return req . headers [ 'user-agent' ] ; } ) ;
29- connect . logger . token ( 'timestamp' , function ( req , res ) { return Date . now ( ) ; } ) ;
30-
37+
38+ connect . logger . token ( 'user-agent' , function ( req , res ) { return req . headers [ 'user-agent' ] ; } ) ;
39+ connect . logger . token ( 'timestamp' , function ( req , res ) { return Date . now ( ) ; } ) ;
40+
3141 return [
3242 connect . json ( ) ,
3343 testResultLoggerMiddleware ,
34-
44+
3545 connect . logger ( { format :'[:user-agent][:timestamp] :method :url' , stream :grunt . verbose } ) ,
3646 connect . static ( options . base ) ,
3747 connect . directory ( options . base )
3848 ] ;
3949 } ,
4050 }
4151 }
42- }
43- }
52+ } ;
53+ } ;
0 commit comments