From 4686c9c66b4db378e24749db8c365510fbed9a27 Mon Sep 17 00:00:00 2001 From: Jordan Nielson Date: Mon, 25 Feb 2019 11:30:03 -0700 Subject: [PATCH] Allow timeout: false to remove a timeout --- README.md | 6 +----- lib/utils.js | 6 +++++- package-lock.json | 2 +- test/terminal-notifier.js | 22 ++++++++++++++++++++++ 4 files changed, 29 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 7ce7978..e588e05 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 40f2521..330c8ff 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -211,7 +211,11 @@ module.exports.mapToMac = function(options) { } if (!options.wait && !options.timeout) { - options.timeout = 10; + if (options.timeout === false) { + delete options.timeout; + } else { + options.timeout = 10; + } } options.json = true; diff --git a/package-lock.json b/package-lock.json index d0cffc0..f1c48db 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "node-notifier", - "version": "5.3.0", + "version": "5.4.0", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/test/terminal-notifier.js b/test/terminal-notifier.js index 056bf58..bb5cecb 100644 --- a/test/terminal-notifier.js +++ b/test/terminal-notifier.js @@ -277,6 +277,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',