Skip to content

Commit

Permalink
Merge pull request #260 from rmobis/master
Browse files Browse the repository at this point in the history
Enables the use of WindowsToaster when using WSL
  • Loading branch information
mikaelbr authored Dec 4, 2018
2 parents ced09c1 + f755869 commit 3050716
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 2 deletions.
8 changes: 7 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ var WindowsBalloon = require('./notifiers/balloon');

var options = { withFallback: true };

switch (os.type()) {
var osType = utils.isWSL() ? 'WSL' : os.type();

switch (osType) {
case 'Linux':
module.exports = new NotifySend(options);
module.exports.Notification = NotifySend;
Expand All @@ -28,6 +30,10 @@ switch (os.type()) {
module.exports.Notification = WindowsToaster;
}
break;
case 'WSL':
module.exports = new WindowsToaster(options);
module.exports.Notification = WindowsToaster;
break;
default:
if (os.type().match(/BSD$/)) {
module.exports = new NotifySend(options);
Expand Down
5 changes: 5 additions & 0 deletions lib/utils.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
var shellwords = require('shellwords');
var cp = require('child_process');
var semver = require('semver');
var isWSL = require('is-wsl');
var path = require('path');
var url = require('url');
var os = require('os');
Expand Down Expand Up @@ -485,6 +486,10 @@ module.exports.isWin8 = function() {
);
};

module.exports.isWSL = function() {
return isWSL;
};

module.exports.isLessThanWin8 = function() {
return (
os.type() === 'Windows_NT' &&
Expand Down
2 changes: 1 addition & 1 deletion notifiers/toaster.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ WindowsToaster.prototype.notify = function(options, callback) {
return this;
}

if (!utils.isWin8() && !!this.options.withFallback) {
if (!utils.isWin8() && !utils.isWSL() && !!this.options.withFallback) {
fallback = fallback || new Balloon(this.options);
return fallback.notify(options, callback);
}
Expand Down
5 changes: 5 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
},
"dependencies": {
"growly": "^1.3.0",
"is-wsl": "^1.1.0",
"semver": "^5.5.0",
"shellwords": "^0.1.1",
"which": "^1.3.0"
Expand Down

0 comments on commit 3050716

Please sign in to comment.