File tree Expand file tree Collapse file tree 1 file changed +14
-2
lines changed Expand file tree Collapse file tree 1 file changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -3,14 +3,21 @@ let program = require('commander');
3
3
4
4
program
5
5
. arguments ( '<jsonFile>' )
6
+ . option ( '-t, --total' , 'Only print the total time' )
6
7
. action ( function ( jsonFile ) {
7
8
let lineReader = require ( 'readline' ) . createInterface ( {
8
9
input : require ( 'fs' ) . createReadStream ( jsonFile )
9
10
} ) ;
10
- console . log ( "class file; function name; execution time (ms);"
11
- + "success; goals covered; total number of goals" ) ;
11
+ const printTotalTime = typeof program . total != 'undefined' ;
12
+ let totalTime = 0.0 ;
13
+ if ( ! printTotalTime )
14
+ console . log ( "class file; function name; execution time (ms);"
15
+ + "success; goals covered; total number of goals" ) ;
12
16
lineReader . on ( 'line' , function ( data ) {
13
17
let json = JSON . parse ( data . toString ( ) ) ;
18
+ totalTime += parseFloat ( json . execTime ) ;
19
+ if ( printTotalTime )
20
+ return ;
14
21
console . log (
15
22
json . classFile + ";" +
16
23
json [ 'function' ] . replace ( / ; / g, "_" ) + "; " +
@@ -19,5 +26,10 @@ program
19
26
( ( typeof json . goals != 'undefined' ) ? json . goals . goalsCovered : "0" ) + ";" +
20
27
( ( typeof json . goals != 'undefined' ) ? json . goals . totalGoals : "" ) ) ;
21
28
} ) ;
29
+ if ( printTotalTime ) {
30
+ lineReader . on ( 'close' , function ( ) {
31
+ console . log ( jsonFile + "; " + totalTime )
32
+ } ) ;
33
+ }
22
34
} )
23
35
. parse ( process . argv ) ;
You can’t perform that action at this time.
0 commit comments