Skip to content

Commit 99d0902

Browse files
committed
Merge pull request #5 from 1337programming/liyutech-master
Liyutech master
2 parents 0dbcc8b + 093e727 commit 99d0902

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

index.js

+19-2
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,17 @@ function validateInput(options) {
1414
if (typeof options.onBuildEnd === 'string') {
1515
options.onBuildEnd = options.onBuildEnd.split('&&');
1616
}
17+
if (typeof options.onExit === 'string') {
18+
options.onExit = options.onExit.split('&&');
19+
}
1720
return options;
1821
}
1922

2023
function WebpackShellPlugin(options) {
2124
var defaultOptions = {
2225
onBuildStart: [],
2326
onBuildEnd: [],
27+
onExit: [],
2428
dev: true,
2529
verbose: false
2630
};
@@ -33,6 +37,10 @@ function WebpackShellPlugin(options) {
3337
options.onBuildEnd = defaultOptions.onBuildEnd;
3438
}
3539

40+
if (!options.onExit) {
41+
options.onExit = defaultOptions.onExit;
42+
}
43+
3644
if (!options.dev) {
3745
options.dev = defaultOptions.dev;
3846
}
@@ -57,7 +65,7 @@ WebpackShellPlugin.prototype.apply = function (compiler) {
5765
if (options.onBuildStart.length) {
5866
console.log('Executing pre-build scripts');
5967
options.onBuildStart.forEach(function (script) {
60-
exec(script, puts)
68+
exec(script, puts);
6169
});
6270
if (options.dev) {
6371
options.onBuildStart = [];
@@ -69,14 +77,23 @@ WebpackShellPlugin.prototype.apply = function (compiler) {
6977
if (options.onBuildEnd.length) {
7078
console.log('Executing post-build scripts');
7179
options.onBuildEnd.forEach(function (script) {
72-
exec(script, puts)
80+
exec(script, puts);
7381
});
7482
if (options.dev) {
7583
options.onBuildEnd = [];
7684
}
7785
}
7886
callback();
7987
});
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+
});
8097
};
8198

8299
module.exports = WebpackShellPlugin;

0 commit comments

Comments
 (0)