File tree Expand file tree Collapse file tree 3 files changed +24
-0
lines changed Expand file tree Collapse file tree 3 files changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -116,6 +116,13 @@ Show the cursor. This can be useful when a CLI accepts input from a user.
116
116
117
117
Auto clear console when compile is finished.
118
118
119
+ ### ` done `
120
+ - Type: ` Function(sharedState, ctx) `
121
+
122
+ A function that will be called when ** all** builds are finished.
123
+
124
+ This function can optionally return ` false ` as a signal to stop rendering and printing profile stats.
125
+
119
126
<h2 align =" center " >Maintainers</h2 >
120
127
121
128
<table >
Original file line number Diff line number Diff line change @@ -23,6 +23,7 @@ const defaults = {
23
23
clear : true ,
24
24
showCursor : false ,
25
25
enabled : process . stdout . isTTY && ! isCI ,
26
+ done : null ,
26
27
} ;
27
28
28
29
export default class WebpackBarPlugin extends webpack . ProgressPlugin {
@@ -76,6 +77,18 @@ export default class WebpackBarPlugin extends webpack.ProgressPlugin {
76
77
return ;
77
78
}
78
79
80
+ if ( Object . values ( sharedState ) . find ( ( s ) => s . isRunning ) ) {
81
+ return ;
82
+ }
83
+
84
+ if ( typeof this . options . done === 'function' ) {
85
+ const result = this . options . done ( sharedState , this ) ;
86
+ if ( result === false ) {
87
+ // Special signal to do nothing
88
+ return ;
89
+ }
90
+ }
91
+
79
92
this . render ( ) ;
80
93
81
94
if ( this . options . profile ) {
Original file line number Diff line number Diff line change @@ -16,13 +16,16 @@ describe('webpackbar', () => {
16
16
const logUpdate = mockLogUpdate ( ) ;
17
17
18
18
test ( 'compile' , async ( ) => {
19
+ const done = jest . fn ( ) ;
20
+
19
21
const compiler = webpack (
20
22
basicConfig . from ( {
21
23
name : 'test1' ,
22
24
enabled : true ,
23
25
profile : true ,
24
26
color : '#202020' ,
25
27
logUpdate,
28
+ done,
26
29
} )
27
30
) ;
28
31
@@ -31,6 +34,7 @@ describe('webpackbar', () => {
31
34
32
35
expect ( stats . hasErrors ( ) ) . toBe ( false ) ;
33
36
expect ( stats . hasWarnings ( ) ) . toBe ( false ) ;
37
+ expect ( done ) . toHaveBeenCalledTimes ( 1 ) ;
34
38
} ) ;
35
39
36
40
test ( 'logUpdate' , ( ) => {
You can’t perform that action at this time.
0 commit comments