gulp-notify
Advanced tools
Comparing version 1.3.1 to 1.4.0
@@ -5,2 +5,3 @@ | ||
var through = require('through2'); | ||
var path = require('path'); | ||
var plumber = require('gulp-plumber'); | ||
@@ -65,3 +66,3 @@ var nn = require('node-notifier'); | ||
gulp.task("advanceMac", function () { | ||
gulp.task("advanced", function () { | ||
gulp.src("../test/fixtures/*") | ||
@@ -73,4 +74,5 @@ .pipe(notify({ | ||
"sound": "Frog", // case sensitive | ||
// "contentImage": "file:///Some/Image/Here.png", // case sensitive | ||
"open": "https://github.com/mikaelbr/gulp-notify" | ||
"icon": path.join(__dirname, "gulp.png"), // case sensitive | ||
"open": "https://github.com/mikaelbr/gulp-notify", | ||
"onLast": true | ||
})); | ||
@@ -77,0 +79,0 @@ }); |
@@ -5,6 +5,17 @@ var template = require("lodash.template"); | ||
var extend = require("node.extend"); | ||
var path = require("path"); | ||
"use strict"; | ||
var defaults = { | ||
error: { | ||
icon: path.join(__dirname, '..', 'assets', 'gulp-error.png'), | ||
sound: 'Frog' | ||
}, | ||
regular: { | ||
icon: path.join(__dirname, '..', 'assets', 'gulp.png') | ||
} | ||
}; | ||
module.exports = function (reporter, message, options, templateOptions, callback) { | ||
@@ -36,3 +47,3 @@ var self = this; | ||
return extend(outputData, { | ||
return extend(defaults.error, outputData, { | ||
title: titleTemplate({ | ||
@@ -49,3 +60,3 @@ error: object, | ||
return extend(outputData, { | ||
return extend(defaults.regular, outputData, { | ||
title: gutil.template(title, { | ||
@@ -52,0 +63,0 @@ file: object, |
{ | ||
"name": "gulp-notify", | ||
"version": "1.3.1", | ||
"version": "1.4.0", | ||
"description": "A plugin for Gulp to send notification messages (Mac, Linux and Windows", | ||
@@ -28,13 +28,13 @@ "keywords": [ | ||
"dependencies": { | ||
"through2": "~0.4.0", | ||
"through2": "^1.0.0", | ||
"gulp-util": "~2.2.12", | ||
"lodash.template": "~2.4.1", | ||
"node-notifier": "^3.0.0", | ||
"node-notifier": "^3.0.6", | ||
"node.extend": "^1.0.9" | ||
}, | ||
"devDependencies": { | ||
"mocha": "~1.17.1", | ||
"should": "~3.1.2", | ||
"gulp": "~3.5.2", | ||
"gulp-plumber": "~0.5.6" | ||
"mocha": "^1.19.0", | ||
"should": "^3.3.2", | ||
"gulp": "^3.6.2", | ||
"gulp-plumber": "^0.6.2" | ||
}, | ||
@@ -41,0 +41,0 @@ "engines": { |
@@ -8,8 +8,10 @@ # gulp-notify [![NPM version][npm-image]][npm-url] [![Build Status][travis-image]][travis-url] [![Dependency Status][depstat-image]][depstat-url] | ||
| ------------- |--------------| | ||
| Description | Send messages to Mac Notification Center or Linux notifications (using `notify-send`) using the [node-notifier](https://github.com/mikaelbr/node-notifier) module or Growl if not any of them. Can also [specify custom notifier](#notifywithreporterfunction). | | ||
| Node Version | >= 0.8 | | ||
| Package Version | 1.3.0 | | ||
| Description | Send messages to Mac Notification Center, Linux notifications (using `notify-send`) or Windows w/Growl using the [node-notifier](https://github.com/mikaelbr/node-notifier) module. Can also [specify custom notifier](#notifywithreporterfunction). | | ||
| Node Version | >= 0.8 | | ||
| Package Version | 1.4.0 | | ||
**Note: Without overriding the notifier, Mac OS X >= 10.8 or as of v0.3.2, Linux with `notify-send` installed is required for this to run.** | ||
**After version `1.1.0` this now supports Growl natively.** | ||
## Requirements | ||
* **Mac OS X**: No external installation needed (if Mac OS X 10.8 or higher). | ||
* **Linux**: `Notify-send` should be installed (On Ubuntu this is installed per default) | ||
* **Windows**: [Growl for Windows](http://www.growlforwindows.com/gfw/default.aspx) should be installed. | ||
@@ -86,7 +88,14 @@ ## Usage | ||
*Options are passed onto the reporter, so on Windows, you can define | ||
Growl host and so on. See [node-notifier](https://github.com/mikaelbr/node-notifier) | ||
for more information* | ||
Growl host, on Mac you can pass in contentImage, and so on. | ||
See also the [advanceMac example](examples/gulpfile.js). | ||
See [node-notifier](https://github.com/mikaelbr/node-notifier) | ||
for all options* | ||
Default notification values: | ||
- Gulp logo on regular notification | ||
- Inverted Gulp logo on error | ||
- Frog sound on error on Mac. | ||
See also the [advanced example](examples/gulpfile.js). | ||
#### options.onLast | ||
@@ -339,2 +348,5 @@ Type: `Boolean` | ||
### `v1.4.0` | ||
1. Adds default icons for regular notification and error. Also adds Frog sound on error on Mac. | ||
### `v1.3.1` | ||
@@ -370,2 +382,4 @@ 1. Updates node-notifier dependency. Adds support for app icon and images for Mac. | ||
[![NPM downloads][npm-downloads]][npm-url] | ||
## License | ||
@@ -376,8 +390,9 @@ | ||
[npm-url]: https://npmjs.org/package/gulp-notify | ||
[npm-image]: https://badge.fury.io/js/gulp-notify.png | ||
[npm-image]: http://img.shields.io/npm/v/gulp-notify.svg?style=flat | ||
[npm-downloads]: http://img.shields.io/npm/dm/gulp-notify.svg?style=flat | ||
[travis-url]: http://travis-ci.org/mikaelbr/gulp-notify | ||
[travis-image]: https://secure.travis-ci.org/mikaelbr/gulp-notify.png?branch=master | ||
[travis-image]: http://img.shields.io/travis/mikaelbr/gulp-notify.svg?style=flat | ||
[depstat-url]: https://david-dm.org/mikaelbr/gulp-notify | ||
[depstat-image]: https://david-dm.org/mikaelbr/gulp-notify.png | ||
[depstat-url]: https://gemnasium.com/mikaelbr/gulp-notify | ||
[depstat-image]: http://img.shields.io/gemnasium/mikaelbr/gulp-notify.svg?style=flat |
117
test/main.js
@@ -51,28 +51,55 @@ /*global describe, it*/ | ||
it('should call notifier with title and message', function(done) { | ||
it('should set message, title and have default icon of Gulp logo', function(done) { | ||
var testString = "this is a test"; | ||
var expectedIcon = join(__dirname, '..', 'assets', 'gulp.png'); | ||
var expectedFile = new gutil.File({ | ||
path: "test/fixtures/1.txt", | ||
cwd: "test/", | ||
base: "test/fixtures/", | ||
contents: fs.createReadStream("test/fixtures/1.txt") | ||
}); | ||
var mockedNotify = notify.withReporter(mockGenerator(function (opts) { | ||
should.exist(opts); | ||
should.exist(opts.title); | ||
should.exist(opts.message); | ||
opts.should.have.property('title'); | ||
opts.should.have.property('message'); | ||
opts.should.have.property('icon'); | ||
String(opts.icon).should.equal(expectedIcon); | ||
String(opts.message).should.equal(testString); | ||
})); | ||
done(); | ||
}.bind(this))); | ||
var instream = gulp.src(join(__dirname, "./fixtures/*.txt")), | ||
outstream = mockedNotify({ | ||
var outstream = mockedNotify({ | ||
message: testString | ||
}); | ||
outstream.on('data', function(file) { | ||
should.exist(file); | ||
should.exist(file.path); | ||
should.exist(file.contents); | ||
outstream.write(expectedFile); | ||
}); | ||
it('should be able to override default icon', function(done) { | ||
var testString = "this is a test"; | ||
var expectedIcon = "testIcon"; | ||
var expectedFile = new gutil.File({ | ||
path: "test/fixtures/1.txt", | ||
cwd: "test/", | ||
base: "test/fixtures/", | ||
contents: fs.createReadStream("test/fixtures/1.txt") | ||
}); | ||
outstream.on('end', function() { | ||
var mockedNotify = notify.withReporter(mockGenerator(function (opts) { | ||
opts.should.have.property('title'); | ||
opts.should.have.property('message'); | ||
opts.should.have.property('icon'); | ||
String(opts.icon).should.equal(expectedIcon); | ||
String(opts.message).should.equal(testString); | ||
done(); | ||
}); | ||
}.bind(this))); | ||
instream.pipe(outstream); | ||
var outstream = mockedNotify({ | ||
message: testString, | ||
icon: expectedIcon | ||
}); | ||
outstream.write(expectedFile); | ||
}); | ||
@@ -620,2 +647,5 @@ | ||
it('should have onError options on withReporter sugar', function (done) { | ||
var | ||
testMessage = "tester", | ||
srcFile = join(__dirname, "./fixtures/*"); | ||
@@ -630,2 +660,14 @@ var custom = notify.withReporter(mockGenerator(function (opts) { | ||
})); | ||
gulp.src(srcFile) | ||
.pipe(through.obj(function (file, enc, cb) { | ||
this.emit("error", new gutil.PluginError("testPlugin", testMessage)); | ||
cb(); | ||
})) | ||
.on("error", custom.onError()) | ||
}); | ||
it('should have default Gulp-error logo onError', function (done) { | ||
var expectedIcon = join(__dirname, '..', 'assets', 'gulp-error.png'); | ||
var | ||
@@ -635,2 +677,13 @@ testMessage = "tester", | ||
var custom = notify.withReporter(mockGenerator(function (opts) { | ||
should.exist(opts); | ||
should.exist(opts.title); | ||
should.exist(opts.message); | ||
should.exist(opts.icon); | ||
String(opts.message).should.equal(testMessage); | ||
String(opts.icon).should.equal(expectedIcon); | ||
String(opts.title).should.equal("Error running Gulp"); | ||
done(); | ||
})); | ||
gulp.src(srcFile) | ||
@@ -644,2 +697,38 @@ .pipe(through.obj(function (file, enc, cb) { | ||
it('should be able to override default icon onError', function (done) { | ||
var expectedIcon = "testIcon"; | ||
var testMessage = "tester"; | ||
var custom = notify.withReporter(mockGenerator(function (opts) { | ||
should.exist(opts); | ||
should.exist(opts.title); | ||
should.exist(opts.message); | ||
should.exist(opts.icon); | ||
String(opts.message).should.equal(testMessage); | ||
String(opts.icon).should.equal(expectedIcon); | ||
String(opts.title).should.equal("Error running Gulp"); | ||
done(); | ||
})); | ||
custom.onError({ | ||
icon: expectedIcon, | ||
})(new gutil.PluginError("testPlugin", testMessage)); | ||
}); | ||
it('should have Frog sound per default onError', function (done) { | ||
var expectedIcon = "testIcon"; | ||
var testMessage = "tester"; | ||
var custom = notify.withReporter(mockGenerator(function (opts) { | ||
should.exist(opts); | ||
should.exist(opts.sound); | ||
String(opts.sound).should.equal('Frog'); | ||
done(); | ||
})); | ||
custom.onError({ | ||
icon: expectedIcon, | ||
})(new gutil.PluginError("testPlugin", testMessage)); | ||
}); | ||
it('should support lodash template for titles and messages on onError', function (done) { | ||
@@ -646,0 +735,0 @@ var testString = "Template: <%= error.message %>"; |
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
76747
22
1014
394
+ Addedthrough2@1.1.1(transitive)
+ Addedxtend@4.0.2(transitive)
- Removedobject-keys@0.4.0(transitive)
- Removedthrough2@0.4.2(transitive)
- Removedxtend@2.1.2(transitive)
Updatednode-notifier@^3.0.6
Updatedthrough2@^1.0.0