File tree Expand file tree Collapse file tree 1 file changed +29
-7
lines changed Expand file tree Collapse file tree 1 file changed +29
-7
lines changed Original file line number Diff line number Diff line change
1
+ import chalk from 'chalk' ;
2
+
3
+ import { colorize } from '../utils/cli' ;
1
4
import Profiler from '../profiler' ;
2
5
3
6
export default class ProfileReporter {
4
- constructor ( ) {
5
- this . profiler = new Profiler ( ) ;
7
+ progress ( context ) {
8
+ if ( ! context . profiler ) {
9
+ context . profiler = new Profiler ( ) ;
10
+ }
11
+
12
+ context . profiler . onRequest ( context . state . request ) ;
6
13
}
7
14
8
- allDone ( ) {
9
- const formattedStats = this . profiler . getFormattedStats ( ) ;
10
- process . stderr . write ( `\n${ formattedStats } \n` ) ;
15
+ done ( context ) {
16
+ if ( context . profiler ) {
17
+ context . state . profile = context . profiler . getFormattedStats ( ) ;
18
+ delete context . profiler ;
19
+ }
11
20
}
12
21
13
- progress ( context ) {
14
- this . profiler . onRequest ( context . state . request ) ;
22
+ allDone ( context ) {
23
+ let str = '' ;
24
+
25
+ for ( const state of context . statesArray ) {
26
+ const color = colorize ( state . color ) ;
27
+
28
+ if ( state . profile ) {
29
+ str +=
30
+ color ( `\nProfile results for ${ chalk . bold ( state . name ) } \n` ) +
31
+ `\n${ state . profile } \n` ;
32
+ delete state . profile ;
33
+ }
34
+ }
35
+
36
+ process . stderr . write ( str ) ;
15
37
}
16
38
}
You can’t perform that action at this time.
0 commit comments