Skip to content

Commit

Permalink
Merge PR Turbo87#51: Add onlyOnError option
Browse files Browse the repository at this point in the history
# Conflicts:
#	CHANGELOG.md
  • Loading branch information
Игорь Звягинцев committed Dec 10, 2019
2 parents a3634a5 + f10d092 commit 20060fa
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Expand Up @@ -2,6 +2,12 @@
Changelog
===============================================================================

v1.9.0
-------------------------------------------------------------------------------

- Add `onlyOnError` option ([#51](https://github.com/Turbo87/webpack-notifier/pull/51)


v1.8.0
-------------------------------------------------------------------------------

Expand Down
10 changes: 9 additions & 1 deletion README.md
Expand Up @@ -78,12 +78,20 @@ new WebpackNotifierPlugin({excludeWarnings: true});

### Always Notify

Trigger a notification every time. Call it "noisy-mode".
Trigger a notification every time. Call it "noisy-mode".

```js
new WebpackNotifierPlugin({alwaysNotify: true});
```

### Notify on error

Trigger a notification only on error.

```js
new WebpackNotifierPlugin({onlyOnError: true});
```

### Skip Notification on the First Build

Do not notify on the first build. This allows you to receive notifications on subsequent incremental builds without being notified on the initial build.
Expand Down
6 changes: 3 additions & 3 deletions index.js
Expand Up @@ -40,10 +40,10 @@ WebpackNotifierPlugin.prototype.compileMessage = function(stats) {
if (stats.hasErrors()) {
error = findFirstDFS(stats.compilation, 'errors');

} else if (stats.hasWarnings() && !this.options.excludeWarnings) {
} else if (stats.hasWarnings() && !this.options.excludeWarnings && !this.options.onlyOnError) {
error = findFirstDFS(stats.compilation, 'warnings');

} else if (!this.lastBuildSucceeded || this.options.alwaysNotify) {
} else if ((!this.lastBuildSucceeded || this.options.alwaysNotify) && !this.options.onlyOnError) {
this.lastBuildSucceeded = true;
return (hasEmoji ? '✅ ' : '') + 'Build successful';

Expand All @@ -53,7 +53,7 @@ WebpackNotifierPlugin.prototype.compileMessage = function(stats) {

this.lastBuildSucceeded = false;

var message;
var message = '';
if (error.module && error.module.rawRequest)
message = error.module.rawRequest + '\n';

Expand Down

0 comments on commit 20060fa

Please sign in to comment.