node-notifier
Advanced tools
Comparing version 1.1.2-0 to 1.2.0
@@ -7,5 +7,6 @@ /** | ||
, os = require('os') | ||
, which = require('which') | ||
, utils = require('./utils'); | ||
var notifier = 'notify-send' | ||
var notifier = 'notify-send'; | ||
@@ -16,2 +17,4 @@ var Notifier = function () { | ||
} | ||
this.isNotifyChecked = false; | ||
this.hasNotifier = false; | ||
} | ||
@@ -34,3 +37,18 @@ , constructArgumentList = function (options, initial) { | ||
var doNotification = function (options, callback) { | ||
options.title = options.title || 'Node Notification:'; | ||
var initial = [options.title, options.message]; | ||
delete options.title; | ||
delete options.message; | ||
var argsList = constructArgumentList(options, initial); | ||
callback = callback || function (err, data) {}; | ||
utils.command(notifier, argsList, callback); | ||
return this; | ||
}; | ||
Notifier.prototype.notify = function (options, callback) { | ||
var that = this; | ||
options = options || {}; | ||
@@ -47,11 +65,21 @@ if (!options.message) { | ||
options.title = options.title || 'Node Notification:'; | ||
var initial = [options.title, options.message]; | ||
if (this.isNotifyChecked && this.hasNotifier) { | ||
return doNotification(options, callback); | ||
} | ||
delete options.title; | ||
delete options.message; | ||
var argsList = constructArgumentList(options, initial); | ||
callback = callback || function (err, data) {}; | ||
if (this.isNotifyChecked && !this.hasNotifier) { | ||
callback(new Error('notify-send must be installed on the system.')); | ||
return this; | ||
} | ||
utils.command(notifier, argsList, callback); | ||
which(notifier, function (err) { | ||
that.isNotifyChecked = true; | ||
that.hasNotifier = !!err; | ||
if (err) { | ||
return callback(err); | ||
} | ||
return doNotification(options, callback); | ||
}); | ||
return this; | ||
@@ -58,0 +86,0 @@ }; |
{ | ||
"name": "node-notifier", | ||
"version": "1.1.2-0", | ||
"version": "1.2.0", | ||
"description": "A Node.js wrapper for the terminal-notifier application", | ||
@@ -24,3 +24,6 @@ "main": "index.js", | ||
"should": "~1.2.1" | ||
}, | ||
"dependencies": { | ||
"which": "~1.0.5" | ||
} | ||
} |
@@ -1,2 +0,2 @@ | ||
var notifier = require('../lib/terminal-notifier') | ||
var notifier = require('../') | ||
, should = require('should') | ||
@@ -3,0 +3,0 @@ , assert = require('assert'); |
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
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
448370
304
1
1
+ Addedwhich@~1.0.5
+ Addedwhich@1.0.9(transitive)