You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

52 lines
1.6 KiB

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