Skip to content

Commit 43a0b1d

Browse files
committed
Provide support for emitting watcher
1 parent 4407f82 commit 43a0b1d

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

lib/index.js

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,18 @@ var defaultOptions = {
3434
onBuildEnd: [],
3535
onBuildExit: [],
3636
dev: true,
37-
verbose: false,
38-
watch: false
37+
verbose: false
3938
};
4039

4140
function puts(error, stdout, stderr) {
4241
if (error) {
4342
console.log('Error: ', error, stderr);
4443
}
45-
console.log(stdout);
44+
}
45+
46+
function spreadStdoutAndStdErr(proc) {
47+
proc.stdout.pipe(process.stdout);
48+
proc.stderr.pipe(process.stdout);
4649
}
4750

4851
function validateInput(options) {
@@ -86,7 +89,7 @@ var WebpackShellPlugin = function () {
8689
if (_this.options.onBuildStart.length) {
8790
console.log('Executing pre-build scripts');
8891
_this.options.onBuildStart.forEach(function (script) {
89-
exec(script, puts);
92+
spreadStdoutAndStdErr(exec(script, puts));
9093
});
9194
if (_this.options.dev) {
9295
_this.options.onBuildStart = [];
@@ -95,14 +98,10 @@ var WebpackShellPlugin = function () {
9598
});
9699

97100
compiler.plugin('emit', function (compilation, callback) {
98-
for (var key in compilation.options) {
99-
console.log(key);
100-
}
101-
console.log('EMITTING');
102101
if (_this.options.onBuildEnd.length) {
103102
console.log('Executing post-build scripts');
104103
_this.options.onBuildEnd.forEach(function (script) {
105-
exec(script, puts);
104+
spreadStdoutAndStdErr(exec(script, puts));
106105
});
107106
if (_this.options.dev) {
108107
_this.options.onBuildEnd = [];
@@ -115,7 +114,7 @@ var WebpackShellPlugin = function () {
115114
if (_this.options.onBuildExit.length) {
116115
console.log('Executing additional scripts before exit');
117116
_this.options.onBuildExit.forEach(function (script) {
118-
exec(script, puts);
117+
spreadStdoutAndStdErr(exec(script, puts));
119118
});
120119
}
121120
});

0 commit comments

Comments
 (0)