node-notifier
Advanced tools
Comparing version 1.2.1 to 2.0.0-alpha
20
index.js
var os = require('os'); | ||
var notifier = (os.type() === 'Linux') ? 'notify-send' : 'terminal-notifier'; | ||
module.exports = require('./lib/' + notifier); | ||
var send = require('./lib/notifiers/notify-send'); | ||
var mac = require('./lib/notifiers/terminal-notifier'); | ||
var growl = require('./lib/notifiers/growl'); | ||
switch(os.type()) { | ||
case 'Linux': | ||
module.exports = send; | ||
break; | ||
case 'Darwin': | ||
module.exports = mac; | ||
break; | ||
default: | ||
module.exports = growl; | ||
} | ||
module.exports.NotifySend = send; | ||
module.exports.NotificationCenter = mac; | ||
module.exports.Growl = growl; |
@@ -41,3 +41,2 @@ var child_process = require('child_process') | ||
// Parsing CLI lines and tables.. | ||
var tableLineObject = function (header, splittedLine) { | ||
@@ -113,2 +112,2 @@ var obj = {}, line; | ||
return data; | ||
}; | ||
}; |
{ | ||
"name": "node-notifier", | ||
"version": "1.2.1", | ||
"description": "A Node.js wrapper for the terminal-notifier application", | ||
"version": "2.0.0-alpha", | ||
"description": "A Node.js module for sending notifications on mac, windows and linux", | ||
"main": "index.js", | ||
@@ -10,3 +10,3 @@ "directories": { | ||
"scripts": { | ||
"test": "./node_modules/.bin/mocha" | ||
"test": "./node_modules/.bin/mocha -R spec" | ||
}, | ||
@@ -18,3 +18,5 @@ "repository": "git@github.com:mikaelbr/node-notifier.git", | ||
"notify", | ||
"terminal-notifier" | ||
"terminal-notifier", | ||
"notify-send", | ||
"growl" | ||
], | ||
@@ -28,4 +30,5 @@ "author": "Mikael Brevik", | ||
"dependencies": { | ||
"which": "~1.0.5" | ||
"which": "~1.0.5", | ||
"growler": "0.0.1" | ||
} | ||
} |
# node-notifier | ||
A Node.js wrapper for the [terminal-notifier](https://github.com/alloy/terminal-notifier) application by [Eloy Durán](https://github.com/alloy). | ||
A node module for sending notification using node. Uses terminal-notifier on mac, | ||
notify-send for Linux 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) or Linux with the notify-send module. | ||
- Mac OS X (>= 10.8) | ||
- Linux with the notify-send module | ||
- Or Growl on Windows | ||
@@ -12,2 +19,9 @@ If using Linux, `notify-send` must be installed on your system. | ||
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). | ||
By default Notification Center will be used on Mac, notify-send will be used | ||
on Linux, and Growl will be used if neither mac or linux. | ||
## Install | ||
@@ -18,4 +32,27 @@ ``` | ||
## Standard Usage | ||
```javascript | ||
var Notification = require('node-notifier'); | ||
## Usage | ||
var notifier = new Notification(); | ||
notifier.notify({ | ||
message: 'Hello World' | ||
}); | ||
``` | ||
`Notification` also has specifications for all types of notifications, to be used | ||
manually. | ||
Example: | ||
```javascript | ||
var nn = require('node-notifier'); | ||
new nn.NotificationCenter().notify(); | ||
new nn.NotifySend().notify(); | ||
new nn.Growl().notify(options); | ||
``` | ||
## Usage NotificationCenter | ||
Same usage and parameter setup as [terminal-notifier](https://github.com/alloy/terminal-notifier). | ||
@@ -28,4 +65,5 @@ | ||
```javascript | ||
var notifier = require('node-notifier'); | ||
var Notification = require('node-notifier'); | ||
var notifier = new Notification(); | ||
notifier.notify({ | ||
@@ -40,4 +78,5 @@ message: 'Hello World' | ||
```javascript | ||
var notifier = require('node-notifier'); | ||
var Notification = require('node-notifier'); | ||
var notifier = new Notification(); | ||
notifier.notify({ | ||
@@ -85,9 +124,35 @@ title: 'My application', | ||
## Usage NotifySend | ||
## Module TODO | ||
```javascript | ||
var Notification = require('node-notifier'); | ||
1. Be robust and have unit tests. | ||
var notifier = new Notification(); | ||
notifier.notify({ | ||
title: 'Foo', | ||
message: 'Hello World' | ||
// .. and other notify-send flags | ||
}); | ||
``` | ||
When these criterias are met, the module will be versioned 1.0. | ||
## Usage NotifySend | ||
_NB:_ Previous plans of supporting both growlnotify and terminal-notifier, are abandoned. This module will only do terminal-notifier. | ||
```javascript | ||
var Notification = require('node-notifier'); | ||
var notifier = new Notification({ | ||
// Options as passed to Growler | ||
}); | ||
notifier.notify({ | ||
title: 'Foo', | ||
message: 'Hello World' | ||
// and other growl options like sticky etc. | ||
}); | ||
``` | ||
See more information for constructor options in | ||
[growler](https://github.com/betamos/Node-Growler/). | ||
## Module TODO | ||
1. Add tests for notify-send and growl |
@@ -1,66 +0,77 @@ | ||
var notifier = require('../') | ||
var NotificationCenter = require('../').NotificationCenter | ||
, should = require('should') | ||
, os = require('os') | ||
, assert = require('assert'); | ||
describe('node-notifier', function(){ | ||
var notifier = new NotificationCenter(); | ||
describe('#notify()', function(){ | ||
(function () { | ||
before(function (done) { | ||
notifier.notify({ | ||
remove: "ALL" | ||
}, function () { done(); }); | ||
}); | ||
if (os.type() !== 'Darwin') { | ||
console.log('Only tests for Mac for now.'); | ||
return; | ||
} | ||
it('should notify with a message', function(done){ | ||
describe('node-notifier', function(){ | ||
notifier.notify({ | ||
message: "Hello World" | ||
}, function (err, response) { | ||
response.type.should.equal("delivered"); | ||
done(); | ||
describe('#notify()', function(){ | ||
before(function (done) { | ||
notifier.notify({ | ||
remove: "ALL" | ||
}, function () { done(); }); | ||
}); | ||
}); | ||
it('should notify with a message', function(done){ | ||
it('should be chainable', function(done){ | ||
notifier.notify({ | ||
message: "Hello World" | ||
}, function (err, response) { | ||
response.type.should.equal("delivered"); | ||
done(); | ||
}); | ||
notifier.notify({ | ||
message: "First test" | ||
}).notify({ | ||
message: "Second test" | ||
}, function (err, response) { | ||
response.type.should.equal("delivered"); | ||
response.response[0].should.equal("Notification delivered."); | ||
done(); | ||
}); | ||
}); | ||
it('should be chainable', function(done){ | ||
it('should be able to list all notifications', function(done){ | ||
notifier.notify({ | ||
list: "ALL" | ||
notifier.notify({ | ||
message: "First test" | ||
}).notify({ | ||
message: "Second test" | ||
}, function (err, response) { | ||
response.response.length.should.equal(3); | ||
response.type.should.equal("delivered"); | ||
response.response[0].should.equal("Notification delivered."); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
it('should be able to remove all messages', function(done){ | ||
notifier.notify({ | ||
remove: "ALL" | ||
}, function (err, response) { | ||
response.type.should.equal("removed"); | ||
it('should be able to list all notifications', function(done){ | ||
notifier.notify({ | ||
list: "ALL" | ||
}, function (err, response) { | ||
response.response.length.should.equal(3); | ||
done(); | ||
}); | ||
}); | ||
it('should be able to remove all messages', function(done){ | ||
notifier.notify({ | ||
list: "ALL" | ||
remove: "ALL" | ||
}, function (err, response) { | ||
assert(!response); | ||
done(); | ||
response.type.should.equal("removed"); | ||
notifier.notify({ | ||
list: "ALL" | ||
}, function (err, response) { | ||
assert(!response); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); | ||
}()); |
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
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
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
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
451694
19
377
154
1
2
2
+ Addedgrowler@0.0.1
+ Addedgrowler@0.0.1(transitive)
+ Addedunderscore@1.13.7(transitive)