Skip to content

Commit

Permalink
Add “quiet” option
Browse files Browse the repository at this point in the history
  • Loading branch information
difelice committed May 9, 2017
1 parent a65ae75 commit 0984174
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ Once the build finishes, a child process is spawned firing both a python and nod
* `dev`: switch for development environments. This causes scripts to execute once. Useful for running HMR on webpack-dev-server or webpack watch mode. **Default: true**
* `safe`: switches script execution process from spawn to exec. If running into problems with spawn, turn this setting on. **Default: false**
* `verbose`: **DEPRECATED** enable for verbose output. **Default: false**
* `quiet`: does not outputs any internal messages. **Default: false**

### Developing

Expand Down
21 changes: 15 additions & 6 deletions src/webpack-shell-plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ const defaultOptions = {
onBuildExit: [],
dev: true,
verbose: false,
safe: false
safe: false,
quiet: false
};

export default class WebpackShellPlugin {
Expand Down Expand Up @@ -72,11 +73,15 @@ export default class WebpackShellPlugin {

compiler.plugin('compilation', (compilation) => {
if (this.options.verbose) {
console.log(`Report compilation: ${compilation}`);
console.warn(`WebpackShellPlugin [${new Date()}]: Verbose is being deprecated, please remove.`);
if (!this.options.quiet) {
console.log(`Report compilation: ${compilation}`);
console.warn(`WebpackShellPlugin [${new Date()}]: Verbose is being deprecated, please remove.`);
}
}
if (this.options.onBuildStart.length) {
console.log('Executing pre-build scripts');
if (!this.options.quiet) {
console.log('Executing pre-build scripts');
}
for (let i = 0; i < this.options.onBuildStart.length; i++) {
this.handleScript(this.options.onBuildStart[i]);
}
Expand All @@ -88,7 +93,9 @@ export default class WebpackShellPlugin {

compiler.plugin('after-emit', (compilation, callback) => {
if (this.options.onBuildEnd.length) {
console.log('Executing post-build scripts');
if (!this.options.quiet) {
console.log('Executing post-build scripts');
}
for (let i = 0; i < this.options.onBuildEnd.length; i++) {
this.handleScript(this.options.onBuildEnd[i]);
}
Expand All @@ -101,7 +108,9 @@ export default class WebpackShellPlugin {

compiler.plugin('done', () => {
if (this.options.onBuildExit.length) {
console.log('Executing additional scripts before exit');
if (!this.options.quiet) {
console.log('Executing additional scripts before exit');
}
for (let i = 0; i < this.options.onBuildExit.length; i++) {
this.handleScript(this.options.onBuildExit[i]);
}
Expand Down

0 comments on commit 0984174

Please sign in to comment.