node-notifier
Advanced tools
Comparing version 5.0.2 to 5.1.2
Changelog | ||
=== | ||
### `v5.1.2` | ||
- Adds temporary workaround for `terminal-notifier` memory leak as seen in https://github.com/facebook/jest/issues/2999 and https://github.com/julienXX/terminal-notifier/issues/173. | ||
- Add appName option and hide snoreToast if not setted ([#158](https://github.com/mikaelbr/node-notifier/pull/158)) | ||
### `v5.0.2` | ||
@@ -5,0 +10,0 @@ |
@@ -24,8 +24,3 @@ var shellwords = require('shellwords'); | ||
var inArray = function(arr, val) { | ||
for (var i = 0; i < arr.length; i++) { | ||
if (arr[i] === val) { | ||
return true; | ||
} | ||
} | ||
return false; | ||
return arr.indexOf(val) !== -1; | ||
}; | ||
@@ -57,10 +52,9 @@ | ||
return cp.exec(notifier + ' ' + options.join(' '), function( | ||
error, | ||
stdout, | ||
stderr | ||
) { | ||
if (error) return cb(error); | ||
cb(stderr, stdout); | ||
}); | ||
return cp.exec( | ||
notifier + ' ' + options.join(' '), | ||
function(error, stdout, stderr) { | ||
if (error) return cb(error); | ||
cb(stderr, stdout); | ||
} | ||
); | ||
}; | ||
@@ -183,4 +177,3 @@ | ||
options.icon = fs.readFileSync(options.icon); | ||
} catch (ex) { | ||
} | ||
} catch (ex) {} | ||
} | ||
@@ -227,4 +220,3 @@ | ||
function noop() { | ||
} | ||
function noop() {} | ||
module.exports.actionJackerDecorator = function(emitter, options, fn, mapper) { | ||
@@ -258,3 +250,3 @@ options = clone(options); | ||
fn.apply(emitter, [ err, resultantData, metadata ]); | ||
fn.apply(emitter, [err, resultantData, metadata]); | ||
if (!mapper || !resultantData) return; | ||
@@ -284,5 +276,3 @@ | ||
if (isArray(arg)) { | ||
return removeNewLines( | ||
arg.join(',') | ||
); | ||
return removeNewLines(arg.join(',')); | ||
} | ||
@@ -305,3 +295,3 @@ | ||
options.hasOwnProperty(key) && | ||
(!checkForAllowed || inArray(allowedArguments, key)) | ||
(!checkForAllowed || inArray(allowedArguments, key)) | ||
) { | ||
@@ -355,4 +345,5 @@ if (explicitTrue && options[key] === true) { | ||
// should parse file protocol URL to path | ||
options.p = url.parse(options.icon).pathname | ||
.replace(/^\/(\w:\/)/, '$1') | ||
options.p = url | ||
.parse(options.icon) | ||
.pathname.replace(/^\/(\w:\/)/, '$1') | ||
.replace(/\//g, '\\'); | ||
@@ -376,2 +367,13 @@ } else { | ||
if (options.appName) { | ||
options.appID = options.appName; | ||
delete options.appName; | ||
} else { | ||
options.appID = ' '; | ||
} | ||
if (typeof options.appID === 'undefined') { | ||
options.appID = ' '; | ||
} | ||
if (typeof options.remove !== 'undefined') { | ||
@@ -378,0 +380,0 @@ options.close = options.remove; |
@@ -15,2 +15,4 @@ /** | ||
var FAILSAFE_TIMEOUT = 30 * 1000; | ||
var errorMessageOsX = 'You need Mac OS X 10.8 or above to use NotificationCenter,' + | ||
@@ -33,4 +35,3 @@ ' or use Growl fallback with constructor option {withFallback: true}.'; | ||
function noop() { | ||
} | ||
function noop() {} | ||
NotificationCenter.prototype.notify = function(options, callback) { | ||
@@ -45,8 +46,20 @@ var fallbackNotifier; | ||
} | ||
var timeout; | ||
callback = callback || noop; | ||
if (typeof callback !== 'function') { | ||
throw new TypeError( | ||
'The second argument must be a function callback. You have passed ' + | ||
typeof fn | ||
); | ||
} | ||
var actionJackedCallback = utils.actionJackerDecorator( | ||
this, | ||
options, | ||
callback, | ||
function() { | ||
clearTimeout(timeout); | ||
callback.apply(null, arguments); | ||
}, | ||
function(data) { | ||
@@ -76,5 +89,4 @@ if (activeId !== id) return false; | ||
var argsList = utils.constructArgumentList(options); | ||
if (utils.isMountainLion()) { | ||
utils.fileCommandJson( | ||
var cp = utils.fileCommandJson( | ||
this.options.customPath || notifier, | ||
@@ -84,2 +96,10 @@ argsList, | ||
); | ||
// Redundancy fallback to prevent memory leak | ||
timeout = setTimeout( | ||
function() { | ||
cp.kill('SIGTERM'); | ||
}, | ||
FAILSAFE_TIMEOUT | ||
); | ||
return this; | ||
@@ -86,0 +106,0 @@ } |
{ | ||
"name": "node-notifier", | ||
"version": "5.0.2", | ||
"version": "5.1.2", | ||
"description": "A Node.js module for sending notifications on native Mac, Windows (post and pre 8) and Linux (or Growl as fallback)", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
# node-notifier [![NPM version][npm-image]][npm-url] [![Build Status][travis-image]][travis-url] [![Dependency Status][depstat-image]][depstat-url] | ||
A Node.js module for sending cross platform system notifications. Using | ||
Notification Center for macOS, notify-osd/libnotify-bin for Linux, Toasters for | ||
Windows 8/10, or taskbar Balloons for earlier Windows versions. If none of | ||
these requirements are met, Growl is used. | ||
Send cross platform native notifications using Node.js. Notification Center for macOS, | ||
notify-osd/libnotify-bin for Linux, Toasters for Windows 8/10, or taskbar Balloons for | ||
earlier Windows versions. Growl is used if none of these requirements are met. | ||
[Works well with electron](#within-electron-packaging). | ||
@@ -34,13 +34,11 @@ ![macOS Screenshot](https://raw.githubusercontent.com/mikaelbr/node-notifier/master/example/mac.png) | ||
- **Linux**: `notify-osd` or `libnotify-bin` installed (Ubuntu should have this by default) | ||
- **Windows**: >= 8, task bar balloon if earlier or Growl if that is installed. | ||
- **Windows**: >= 8, task bar balloon for Windows < 8. Growl as fallback. Growl takes precedence over Windows balloons. | ||
- **General Fallback**: Growl | ||
Growl takes precedence over Windows balloons. | ||
See [documentation and flow chart for reporter choice](./DECISION_FLOW.md) | ||
## Install | ||
```shell | ||
npm install --save node-notifier | ||
``` | ||
$ npm install --save node-notifier | ||
``` | ||
@@ -123,3 +121,3 @@ ## Cross-Platform Advanced Usage | ||
Same usage and parameter setup as [terminal-notifier](https://github.com/alloy/terminal-notifier). | ||
Same usage and parameter setup as [terminal-notifier](https://github.com/julienXX/terminal-notifier). | ||
@@ -133,3 +131,3 @@ Native Notification Center requires macOS version 10.8 or higher. If you have | ||
Wrapping around [terminal-notifier](https://github.com/alloy/terminal-notifier), you can | ||
Wrapping around [terminal-notifier](https://github.com/julienXX/terminal-notifier), you can | ||
do all terminal-notifier can do through properties to the `notify` method. E.g. | ||
@@ -183,3 +181,3 @@ if `terminal-notifier` says `-message`, you can do `{message: 'Foo'}`, or | ||
See [specific Notification Center example](./example/advanced.js). | ||
See [specific Notification Center example](./example/advanced.js). Also, [see input example](./example/macInput.js). | ||
@@ -222,3 +220,3 @@ **Custom Path clarification** | ||
id: void 0, // Number. ID to use for closing notification. | ||
appID: void 0, // String. App.ID. Don't create a shortcut but use the provided app id. | ||
appID: void 0, // String. App.ID and app Name. Defaults to empty string. | ||
remove: void 0, // Number. Refer to previously created notification to close. | ||
@@ -284,4 +282,3 @@ install: void 0 // String (path, application, app id). Creates a shortcut <path> in the start menu which point to the executable <application>, appID used for the notifications. | ||
See full usage on the [project homepage: | ||
notifu](http://www.paralint.com/projects/notifu/). | ||
See full usage on the [project homepage: notifu](http://www.paralint.com/projects/notifu/). | ||
@@ -319,3 +316,3 @@ ### Usage NotifySend | ||
`node-notifier` is made possible through Open Source Software. A very special thanks to all the modules `node-notifier` uses. | ||
* [terminal-notifier](https://github.com/alloy/terminal-notifier) | ||
* [terminal-notifier](https://github.com/julienXX/terminal-notifier) | ||
* [Snoretoast](https://github.com/KDE/snoretoast) | ||
@@ -335,3 +332,6 @@ * [notifu](http://www.paralint.com/projects/notifu/) | ||
### Custom icon without terminal icon on macOS | ||
Even if you define an icon in the configuration object for `node-notifier`, you will see a small Terminal icon in the notification (see the example at the top of this document). This is the way notifications on macOS work, it always show the parent icon of the application initiating the notification. For node-notifier, terminal-notifier is the initiator and has Terminal icon defined as its icon. To define your custom icon, you need to fork terminal-notifier and build your custom version with your icon. See this issue for more info: https://github.com/mikaelbr/node-notifier/issues/71 | ||
### Within Electron Packaging | ||
@@ -338,0 +338,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1388572
932