Skip to content

Commit 4407f82

Browse files
committed
propagate stdout and stderr for long running processes
resolves #13
1 parent 945ac24 commit 4407f82

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/webpack-shell-plugin.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,11 @@ function puts(error, stdout, stderr) {
1111
if (error) {
1212
console.log('Error: ', error, stderr);
1313
}
14-
console.log(stdout);
14+
}
15+
16+
function spreadStdoutAndStdErr(proc) {
17+
proc.stdout.pipe(process.stdout);
18+
proc.stderr.pipe(process.stdout);
1519
}
1620

1721
function validateInput(options) {
@@ -50,7 +54,7 @@ export default class WebpackShellPlugin {
5054
if (this.options.onBuildStart.length) {
5155
console.log('Executing pre-build scripts');
5256
this.options.onBuildStart.forEach((script) => {
53-
exec(script, puts);
57+
spreadStdoutAndStdErr(exec(script, puts));
5458
});
5559
if (this.options.dev) {
5660
this.options.onBuildStart = [];
@@ -62,7 +66,7 @@ export default class WebpackShellPlugin {
6266
if (this.options.onBuildEnd.length) {
6367
console.log('Executing post-build scripts');
6468
this.options.onBuildEnd.forEach((script) => {
65-
exec(script, puts);
69+
spreadStdoutAndStdErr(exec(script, puts));
6670
});
6771
if (this.options.dev) {
6872
this.options.onBuildEnd = [];
@@ -75,7 +79,7 @@ export default class WebpackShellPlugin {
7579
if (this.options.onBuildExit.length) {
7680
console.log('Executing additional scripts before exit');
7781
this.options.onBuildExit.forEach((script) => {
78-
exec(script, puts);
82+
spreadStdoutAndStdErr(exec(script, puts));
7983
});
8084
}
8185
});

0 commit comments

Comments
 (0)