diff --git a/README.md b/README.md index 9984361..038ecb8 100644 --- a/README.md +++ b/README.md @@ -186,11 +186,7 @@ notifier.notify( **Note:** The `wait` option is shorthand for `timeout: 5`. This just sets a timeout for 5 seconds. It does _not_ make the notification sticky! -Without `wait` or `timeout`, notifications are just fired and forgotten. They don't -wait for any response. - -To make notifications wait for a response (like activation/click), you must define -a `timeout`. +As of 5.4.0, `timeout` defaults to `10`. In order to have a "fire and forgotten" notification, you need to set `timeout` to `false`. _Exception:_ If `reply` is defined, it's recommended to set `timeout` to a either high value, or to nothing at all. diff --git a/lib/utils.js b/lib/utils.js index 7c75f29..330c8ff 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -210,6 +210,14 @@ module.exports.mapToMac = function(options) { delete options.wait; } + if (!options.wait && !options.timeout) { + if (options.timeout === false) { + delete options.timeout; + } else { + options.timeout = 10; + } + } + options.json = true; return options; }; diff --git a/test/terminal-notifier.js b/test/terminal-notifier.js index ea757f4..513267b 100644 --- a/test/terminal-notifier.js +++ b/test/terminal-notifier.js @@ -273,6 +273,28 @@ describe('terminal-notifier', function() { }); }); + it('should not set a default timeout if explicitly false', function(done) { + var expected = [ + '-title', + '"Title"', + '-message', + '"Message"', + '-json', + '"true"' + ]; + + expectArgsListToBe(expected, done); + var notifier = new NotificationCenter(); + notifier.isNotifyChecked = true; + notifier.hasNotifier = true; + + notifier.notify({ + title: 'Title', + message: 'Message', + timeout: false + }); + }); + it('should escape all title and message', function(done) { var expected = [ '-title',