From 673bfdef09503a5fe5d40aa3d1432a5d1ef1378f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergej=20Mu=CC=88ller?= Date: Sun, 9 Dec 2018 14:55:57 +0100 Subject: [PATCH 1/2] Add onlyOnError option Trigger a notification only on error. --- CHANGELOG.md | 6 ++++++ README.md | 10 +++++++++- index.js | 6 +++--- package.json | 2 +- 4 files changed, 19 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 44beedbc..242f530a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,12 @@ Changelog =============================================================================== +v1.8.0 +------------------------------------------------------------------------------- + +- Add `onlyOnError` option + + v1.7.0 ------------------------------------------------------------------------------- diff --git a/README.md b/README.md index bc031b38..41717e82 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/index.js b/index.js index c7d795ca..91d52912 100644 --- a/index.js +++ b/index.js @@ -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 'Build successful'; @@ -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'; diff --git a/package.json b/package.json index 71c21d7e..41f22f08 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "webpack-notifier", - "version": "1.7.0", + "version": "1.8.0", "description": "webpack + node-notifier = build status system notifications", "main": "index.js", "files": [ From 3962ed2fc64b529486cdfb07b1dcbb5de5b095cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergej=20M=C3=BCller?= Date: Sun, 9 Dec 2018 14:58:48 +0100 Subject: [PATCH 2/2] Add link to the PR --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 242f530a..8bd132f3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,7 @@ Changelog v1.8.0 ------------------------------------------------------------------------------- -- Add `onlyOnError` option +- Add `onlyOnError` option ([#51](https://github.com/Turbo87/webpack-notifier/pull/51) v1.7.0