UNPKG

1.64 kBJavaScriptView Raw
1var os = require('os');
2var utils = require('./lib/utils');
3
4// All notifiers
5var NotifySend = require('./notifiers/notifysend');
6var NotificationCenter = require('./notifiers/notificationcenter');
7var WindowsToaster = require('./notifiers/toaster');
8var Growl = require('./notifiers/growl');
9var WindowsBalloon = require('./notifiers/balloon');
10
11var options = { withFallback: true };
12
13var osType = utils.isWSL() ? 'WSL' : os.type();
14
15switch (osType) {
16 case 'Linux':
17 module.exports = new NotifySend(options);
18 module.exports.Notification = NotifySend;
19 break;
20 case 'Darwin':
21 module.exports = new NotificationCenter(options);
22 module.exports.Notification = NotificationCenter;
23 break;
24 case 'Windows_NT':
25 if (utils.isLessThanWin8()) {
26 module.exports = new WindowsBalloon(options);
27 module.exports.Notification = WindowsBalloon;
28 } else {
29 module.exports = new WindowsToaster(options);
30 module.exports.Notification = WindowsToaster;
31 }
32 break;
33 case 'WSL':
34 module.exports = new WindowsToaster(options);
35 module.exports.Notification = WindowsToaster;
36 break;
37 default:
38 if (os.type().match(/BSD$/)) {
39 module.exports = new NotifySend(options);
40 module.exports.Notification = NotifySend;
41 } else {
42 module.exports = new Growl(options);
43 module.exports.Notification = Growl;
44 }
45}
46
47// Expose notifiers to give full control.
48module.exports.NotifySend = NotifySend;
49module.exports.NotificationCenter = NotificationCenter;
50module.exports.WindowsToaster = WindowsToaster;
51module.exports.WindowsBalloon = WindowsBalloon;
52module.exports.Growl = Growl;