index.js
 1  var os = require('os');
 2  var utils = require('./lib/utils');
 3  
 4  // All notifiers
 5  var NotifySend = require('./notifiers/notifysend');
 6  var NotificationCenter = require('./notifiers/notificationcenter');
 7  var WindowsToaster = require('./notifiers/toaster');
 8  var Growl = require('./notifiers/growl');
 9  var WindowsBalloon = require('./notifiers/balloon');
10  
11  var options = { withFallback: true };
12  
13  var osType = utils.isWSL() ? 'WSL' : os.type();
14  
15  switch (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.
48  module.exports.NotifySend = NotifySend;
49  module.exports.NotificationCenter = NotificationCenter;
50  module.exports.WindowsToaster = WindowsToaster;
51  module.exports.WindowsBalloon = WindowsBalloon;
52  module.exports.Growl = Growl;