22 MIT License http://www.opensource.org/licenses/mit-license.php
33 Author Tobias Koppers @sokra
44*/
5- function ProgressPlugin ( handler ) {
6- this . handler = handler ;
5+ function ProgressPlugin ( options ) {
6+ if ( typeof options === "function" ) {
7+ options = {
8+ handler : options
9+ } ;
10+ }
11+ options = options || { } ;
12+ this . profile = options . profile ;
13+ this . handler = options . handler ;
714}
815module . exports = ProgressPlugin ;
916
1017ProgressPlugin . prototype . apply = function ( compiler ) {
1118 var handler = this . handler || defaultHandler ;
19+ var profile = this . profile ;
1220 if ( compiler . compilers ) {
1321 var states = new Array ( compiler . compilers . length ) ;
1422 compiler . compilers . forEach ( function ( compiler , idx ) {
@@ -18,9 +26,7 @@ ProgressPlugin.prototype.apply = function(compiler) {
1826 return state && state [ 0 ] || 0 ;
1927 } ) . reduce ( function ( a , b ) {
2028 return a + b ;
21- } ) / states . length , states . map ( function ( state ) {
22- return state && state [ 1 ] ;
23- } ) . filter ( Boolean ) . join ( " | " ) ]
29+ } ) / states . length , "[" + idx + "] " + msg ]
2430 . concat ( Array . prototype . slice . call ( arguments , 2 ) ) ) ;
2531 } ) ) ;
2632 } ) ;
@@ -146,7 +152,7 @@ ProgressPlugin.prototype.apply = function(compiler) {
146152 msg += " " + detail
147153 } ) ;
148154 }
149- if ( compiler . options . profile ) {
155+ if ( profile ) {
150156 state = state . replace ( / ^ \d + \/ \d + \s + / , "" ) ;
151157 if ( percentage === 0 ) {
152158 lastState = null ;
0 commit comments