Skip to content

Commit

Permalink
Fix for Windows notifications (#20).
Browse files Browse the repository at this point in the history
  • Loading branch information
RoccoC committed Dec 13, 2017
1 parent ed123d4 commit ee20cbb
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,11 @@ Given the purpose and similarities, this project probably should have been a for

Changelog
---------
#### 0.1.19
###### _December 13, 2017_

- Added appName parameter to notify config to resolve issue with notifications not being generated in Windows build >=1709 [#20](/../../issues/20).

#### 0.1.18
###### _November 30, 2017_

Expand Down
17 changes: 17 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,26 @@
* A Webpack plugin that generates OS notifications for build steps using node-notifier.
*/
var path = require('path');
var process = require('process');
var os = require('os');
var notifier = require('node-notifier');
var stripAnsi = require('strip-ansi');
var exec = require('child_process').exec;

// determine appId, needed for Windows Toast notifications
// this is necessary post Windows build 1709, where all notifications must
// be generated by a valid application.
// https://github.com/RoccoC/webpack-build-notifier/issues/20
var appId = '';
if (process.platform === 'win32') {
if (process.arch === 'x64') {
appId = '{6D809377-6AF0-444b-8957-A3773F02200E}';
} else {
appId = '{7C5A40EF-A0FB-4BFC-874A-C0F2E0B9FA8E}';
}
appId += "\\nodejs\\node.exe";
}

var WebpackBuildNotifierPlugin = function(cfg) {
cfg = cfg || {};

Expand Down Expand Up @@ -138,6 +153,7 @@ WebpackBuildNotifierPlugin.prototype.activateTerminalWindow = function() {

WebpackBuildNotifierPlugin.prototype.onCompilationWatchRun = function(compilation, callback) {
notifier.notify({
appName: appId,
title: this.title,
message: 'Compilation started...',
contentImage: this.logo,
Expand Down Expand Up @@ -181,6 +197,7 @@ WebpackBuildNotifierPlugin.prototype.onCompilationDone = function(results) {

if (notify) {
notifier.notify({
appName: appId,
title: title,
message: stripAnsi(msg),
sound: sound,
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "webpack-build-notifier",
"version": "0.1.18",
"version": "0.1.19",
"description": "A Webpack plugin that generates OS notifications for build steps using node-notifier.",
"main": "index.js",
"scripts": {
Expand Down

0 comments on commit ee20cbb

Please sign in to comment.