node-notifier
Advanced tools
Comparing version 3.1.3 to 3.2.0
var os = require('os'); | ||
var send = require('./lib/notifiers/notify-send'); | ||
var mac = require('./lib/notifiers/terminal-notifier'); | ||
var win = require('./lib/notifiers/toaster'); | ||
var growl = require('./lib/notifiers/growl'); | ||
@@ -13,2 +14,5 @@ | ||
break; | ||
case 'Windows_NT': | ||
module.exports = win; | ||
break; | ||
default: | ||
@@ -20,2 +24,3 @@ module.exports = growl; | ||
module.exports.NotificationCenter = mac; | ||
module.exports.WindowsToaster = win; | ||
module.exports.Growl = growl; |
@@ -6,2 +6,3 @@ var cp = require('child_process') | ||
, shellwords = require('shellwords') | ||
, semver = require('semver') | ||
; | ||
@@ -42,2 +43,3 @@ | ||
module.exports.command = function (notifier, options, cb) { | ||
var notifyApp = cp.exec(shellwords.escape(notifier) + ' ' + options.join(' '), function (error, stdout, stderr) { | ||
@@ -152,3 +154,4 @@ if (error) { | ||
} | ||
if (Number(stdout.split(".")[1]) >= 8) { | ||
var version = garanteeSemverFormat(stdout.toString().trim()); | ||
if (semver.satisfies(version, '>=10.8')) { | ||
return cb(false); | ||
@@ -161,3 +164,34 @@ } | ||
function OSError() { } | ||
function OSVersionError() { } | ||
function garanteeSemverFormat (version) { | ||
if (version.split('.').length === 2) { | ||
version += '.0'; | ||
} | ||
return version; | ||
}; | ||
module.exports.mapToWin8 = function(options){ | ||
options = mapAppIcon(options); | ||
options = mapText(options); | ||
if(options.icon){ | ||
options.p = options.icon; | ||
delete options.icon; | ||
} | ||
if(options.message){ | ||
options.m = options.message; | ||
delete options.message; | ||
} | ||
if (options.title) { | ||
options.t = options.title; | ||
delete options.title; | ||
} | ||
return options; | ||
}; | ||
module.exports.isWin8 = function(cb){ | ||
return os.type() === 'Windows_NT' && semver.satisfies(os.release(), '>=6.2.9200'); | ||
}; |
{ | ||
"name": "node-notifier", | ||
"version": "3.1.3", | ||
"version": "3.2.0", | ||
"description": "A Node.js module for sending notifications on mac, windows and linux", | ||
@@ -24,10 +24,11 @@ "main": "index.js", | ||
"devDependencies": { | ||
"mocha": "~1.7.4", | ||
"should": "~1.2.1" | ||
"mocha": "^1.21.4", | ||
"should": "^4.0.4" | ||
}, | ||
"dependencies": { | ||
"which": "~1.0.5", | ||
"growler": "0.0.1", | ||
"shellwords": "~0.1.0" | ||
"growler": "^0.0.1", | ||
"semver": "^3.0.1", | ||
"shellwords": "^0.1.0", | ||
"which": "^1.0.5" | ||
} | ||
} | ||
} |
# node-notifier [![NPM version][npm-image]][npm-url] [![Build Status][travis-image]][travis-url] [![Dependency Status][depstat-image]][depstat-url] | ||
A node module for sending notification using node. Uses terminal-notifier on mac, | ||
notify-send for Linux and growl for others. | ||
notify-send for Linux, toaster for Windows 8.1 and Growl for others. | ||
For mac this is a wrapper for the | ||
[terminal-notifier](https://github.com/alloy/terminal-notifier) application by | ||
[Eloy Durán](https://github.com/alloy). | ||
## Requirements | ||
- Mac OS X (>= 10.8. If earlier versions, Growl is used as fallback) | ||
- Linux with the notify-send module | ||
- Or Growl on Windows | ||
- Mac OS X >= 10.8. | ||
- Linux with the notify-osd/notify-send module | ||
- Windows >= 8.1. | ||
- Or if no of the above requirements are met, Growl is used. | ||
If using Linux, `notify-send` must be installed on your system. | ||
However, [terminal-notifier](https://github.com/alloy/terminal-notifier), comes | ||
If using Linux, `notify-osd` must be installed on your system. | ||
For Mac, [terminal-notifier](https://github.com/alloy/terminal-notifier), comes | ||
bundled in the module. So on Mac, not additional installations is necessary. | ||
If using Windows/Growl, `growl` must be installed. For windows see | ||
[Growl for Windows](http://www.growlforwindows.com/gfw/). You can also use | ||
growl on mac, but you need to specify this manually (see API). | ||
This also goes for native Windows (version >=8.1) as well, where | ||
[toaster.exe](https://github.com/nels-o/toaster) is bundled. Note, for native | ||
Windows notifications [a toast must have a shortcut installed (though not | ||
necessarily pinned) to the Start screen or in the Apps | ||
view](http://msdn.microsoft.com/en-in/library/windows/apps/hh779727.aspx) | ||
By default Notification Center will be used on Mac, notify-send will be used | ||
on Linux, and Growl will be used if neither Mac 10.8 or Linux. | ||
If no of the other requirements are met, node-notifier will use Growl. | ||
You have to have Growl installed on your system. See | ||
[Growl for Windows](http://www.growlforwindows.com/gfw/) or | ||
[Growl for Mac](http://growl.info/). | ||
@@ -37,3 +38,4 @@ ## Install | ||
notifier.notify({ | ||
message: 'Hello World' | ||
title: 'My awesome title', | ||
message: 'Hello from node, Mr. User!' | ||
}); | ||
@@ -51,2 +53,3 @@ ``` | ||
new nn.NotifySend().notify(); | ||
new nn.WindowsToaster().notify(options); | ||
new nn.Growl().notify(options); | ||
@@ -90,3 +93,3 @@ ``` | ||
notifier.notify({ | ||
message: 'Hello World' | ||
message: 'Hello World' | ||
}); | ||
@@ -100,8 +103,11 @@ ``` | ||
var notifier = new Notification(); | ||
var notifier = new Notification({ | ||
// Options passed to Growl if fallback | ||
}); | ||
notifier.notify({ | ||
title: 'My application', | ||
message: 'New notification' | ||
title: 'My application', | ||
message: 'New notification' | ||
}, function(error, response) { | ||
console.log(response); | ||
console.log(response); | ||
}); | ||
@@ -134,8 +140,10 @@ ``` | ||
var notifier = new Notification(); | ||
var notifier = new Notification({ | ||
// Options passed to Growl if fallback | ||
}); | ||
notifier.notify({ | ||
title: 'Foo', | ||
message: 'Hello World', | ||
title: 'Foo', | ||
message: 'Hello World', | ||
icon: __dirname + "/coulson.jpg", | ||
// .. and other notify-send flags | ||
// .. and other notify-send flags | ||
}); | ||
@@ -146,2 +154,18 @@ ``` | ||
## Usage Native Windows | ||
```javascript | ||
var Notification = require('node-notifier'); | ||
var notifier = new Notification({ | ||
// Options passed to Growl if fallback | ||
}); | ||
notifier.notify({ | ||
title: 'Foo', | ||
message: 'Hello World', | ||
icon: __dirname + "/coulson.jpg" | ||
}); | ||
``` | ||
## Usage Growl | ||
@@ -153,9 +177,9 @@ | ||
var notifier = new Notification({ | ||
// Options as passed to Growler | ||
// Options as passed to Growler | ||
}); | ||
notifier.notify({ | ||
title: 'Foo', | ||
message: 'Hello World', | ||
title: 'Foo', | ||
message: 'Hello World', | ||
icon: fs.readFileSync(__dirname + "/coulson.jpg") | ||
// and other growl options like sticky etc. | ||
// and other growl options like sticky etc. | ||
}); | ||
@@ -170,2 +194,5 @@ ``` | ||
### `v3.2.0` | ||
1. Adds native Windows 8.1 support. | ||
### `v3.1.0` | ||
@@ -172,0 +199,0 @@ 1. Adds Growl as fallback for Mac OS X pre 10.8. |
Sorry, the diff of this file is not supported yet
Deprecated
MaintenanceThe maintainer of the package marked it as deprecated. This could indicate that a single version should not be used, or that the package is no longer maintained and any new vulnerabilities will not be fixed.
Found 1 instance in 1 package
1196165
30
802
225
4
1
+ Addedsemver@^3.0.1
+ Addedisexe@2.0.0(transitive)
+ Addedsemver@3.0.1(transitive)
+ Addedwhich@1.3.1(transitive)
- Removedwhich@1.0.9(transitive)
Updatedgrowler@^0.0.1
Updatedshellwords@^0.1.0
Updatedwhich@^1.0.5