diff --git a/build/utils/notification.js b/build/utils/notification.js index 47ced88..a946c35 100644 --- a/build/utils/notification.js +++ b/build/utils/notification.js @@ -5,12 +5,14 @@ import notifier from 'node-notifier'; * * Wraps around node-notifier to assign default values. * - * @param {string|object} options - The notification options or a message. - * @param {string} options.title - The notification title. - * @param {string} options.message - The notification message. - * @param {string} options.icon - The notification icon. + * @param {string|object} options - The notification options or a message. + * @param {string} options.title - The notification title. + * @param {string} options.message - The notification message. + * @param {string} options.icon - The notification icon. + * @param {function} callback - The notification callback. + * @return {void} */ -export default function notification(options) { +export default function notification(options, callback) { if (typeof options === 'string') { options = { message: options @@ -25,5 +27,15 @@ export default function notification(options) { options.icon = 'https://user-images.githubusercontent.com/4596862/54868065-c2aea200-4d5e-11e9-9ce3-e0013c15f48c.png'; } - notifier.notify(options); + // If notification does not use a callback, + // shorten the wait before timing out. + if (typeof callback === 'undefined') { + if (typeof options.wait === 'undefined') { + if (typeof options.timeout === 'undefined') { + options.timeout = 5; + } + } + } + + notifier.notify(options, callback); };