diff --git a/package.json b/package.json index 3e1bed380..bafcb748f 100644 --- a/package.json +++ b/package.json @@ -51,7 +51,6 @@ "moment-timezone": "0.5.4", "mousetrap": "^1.5.3", "nock": "^2", - "node-mac-notifier": "0.0.13", "node-uuid": "^1.4", "nslog": "^3", "optimist": "0.4.0", @@ -83,6 +82,9 @@ "underscore.string": "^3.0", "windows-shortcuts": "emorikawa/windows-shortcuts#b0a0fc7" }, + "optionalDependencies": { + "node-mac-notifier": "0.0.13" + }, "packageDependencies": {}, "scripts": { "flow": "flow; test $? -eq 0 -o $? -eq 2", diff --git a/src/native-notifications.es6 b/src/native-notifications.es6 index 2cfd56558..b0c2b5e99 100644 --- a/src/native-notifications.es6 +++ b/src/native-notifications.es6 @@ -1,12 +1,18 @@ /* eslint global-require: 0 */ let MacNotifierNotification = null; +if (process.platform === 'darwin') { + try { + MacNotifierNotification = require('node-mac-notifier'); + } catch (err) { + console.error("node-mac-notifier (a platform-specific optionalDependency) was not installed correctly! Check the Travis build log for errors.") + } +} class NativeNotifications { displayNotification({title, subtitle, body, tag, canReply, onActivate} = {}) { let notif = null; - if (process.platform === 'darwin') { - MacNotifierNotification = MacNotifierNotification || require('node-mac-notifier'); + if (MacNotifierNotification) { notif = new MacNotifierNotification(title, { bundleId: 'com.nylas.nylas-mail', canReply: canReply,