@@ -14,13 +14,17 @@ function validateInput(options) {
14
14
if ( typeof options . onBuildEnd === 'string' ) {
15
15
options . onBuildEnd = options . onBuildEnd . split ( '&&' ) ;
16
16
}
17
+ if ( typeof options . onExit === 'string' ) {
18
+ options . onExit = options . onExit . split ( '&&' ) ;
19
+ }
17
20
return options ;
18
21
}
19
22
20
23
function WebpackShellPlugin ( options ) {
21
24
var defaultOptions = {
22
25
onBuildStart : [ ] ,
23
26
onBuildEnd : [ ] ,
27
+ onExit : [ ] ,
24
28
dev : true ,
25
29
verbose : false
26
30
} ;
@@ -33,6 +37,10 @@ function WebpackShellPlugin(options) {
33
37
options . onBuildEnd = defaultOptions . onBuildEnd ;
34
38
}
35
39
40
+ if ( ! options . onExit ) {
41
+ options . onExit = defaultOptions . onExit ;
42
+ }
43
+
36
44
if ( ! options . dev ) {
37
45
options . dev = defaultOptions . dev ;
38
46
}
@@ -57,7 +65,7 @@ WebpackShellPlugin.prototype.apply = function (compiler) {
57
65
if ( options . onBuildStart . length ) {
58
66
console . log ( 'Executing pre-build scripts' ) ;
59
67
options . onBuildStart . forEach ( function ( script ) {
60
- exec ( script , puts )
68
+ exec ( script , puts ) ;
61
69
} ) ;
62
70
if ( options . dev ) {
63
71
options . onBuildStart = [ ] ;
@@ -69,14 +77,23 @@ WebpackShellPlugin.prototype.apply = function (compiler) {
69
77
if ( options . onBuildEnd . length ) {
70
78
console . log ( 'Executing post-build scripts' ) ;
71
79
options . onBuildEnd . forEach ( function ( script ) {
72
- exec ( script , puts )
80
+ exec ( script , puts ) ;
73
81
} ) ;
74
82
if ( options . dev ) {
75
83
options . onBuildEnd = [ ] ;
76
84
}
77
85
}
78
86
callback ( ) ;
79
87
} ) ;
88
+
89
+ compiler . plugin ( "done" , function ( ) {
90
+ if ( options . onExit . length ) {
91
+ console . log ( "Executing addiotn scripts befor exit" ) ;
92
+ options . onExit . forEach ( function ( script ) {
93
+ exec ( script , puts ) ;
94
+ } ) ;
95
+ }
96
+ } ) ;
80
97
} ;
81
98
82
99
module . exports = WebpackShellPlugin ;
0 commit comments