gulp-notify
Advanced tools
Comparing version 0.2.0 to 0.3.0
25
index.js
@@ -1,2 +0,2 @@ | ||
var through = require("through"), | ||
var through = require("through2"), | ||
path = require("path"), | ||
@@ -15,3 +15,3 @@ gutil = require("gulp-util"), | ||
function notify (file) { | ||
function notify (file, enc, callback) { | ||
var stream = this; | ||
@@ -24,5 +24,6 @@ stream.pause(); | ||
} else { | ||
stream.emit("data", file); | ||
stream.push(file); | ||
} | ||
stream.resume(); | ||
callback(); | ||
}); | ||
@@ -32,21 +33,25 @@ } | ||
if (!options.onLast) { | ||
return through(notify); | ||
return through.obj(notify); | ||
} | ||
// Only send notification on the last file. | ||
return through(function (file) { | ||
return through.obj(function (file, enc, callback) { | ||
lastFile = file; | ||
this.emit("data", file) | ||
}, function () { | ||
this.push(file); | ||
callback(); | ||
}, function (callback) { | ||
var stream = this; | ||
if (!lastFile) { | ||
return stream.emit("end"); | ||
return callback(); | ||
} | ||
report(reporter, lastFile, options, function (err, file) { | ||
if (err) stream.emit("error", err); | ||
if (err) { | ||
stream.emit("error", err); | ||
return callback(); | ||
} | ||
}); | ||
lastFile = null; // reset | ||
stream.emit("end"); | ||
return callback(); | ||
}); | ||
@@ -53,0 +58,0 @@ }; |
{ | ||
"name": "gulp-notify", | ||
"version": "0.2.0", | ||
"version": "0.3.0", | ||
"description": "A plugin for Gulp to send messages to Mac Notification Center", | ||
@@ -30,3 +30,3 @@ "keywords": [ | ||
"node-notifier": ">=1.0.0-beta2", | ||
"through": ">=2.3.4" | ||
"through2": "~0.4.0" | ||
}, | ||
@@ -33,0 +33,0 @@ "devDependencies": { |
@@ -79,2 +79,19 @@ # gulp-notify [![NPM version][npm-image]][npm-url] [![Build Status][travis-image]][travis-url] [![Dependency Status][depstat-image]][depstat-url] | ||
### notify.onError() | ||
Same API as using `notify()`, but instead of being passed `vinyl File` an | ||
error object gets sent. | ||
Example: | ||
```javascript | ||
gulp.src("../test/fixtures/*") | ||
.pipe(through(function () { | ||
this.emit("error", "Something happend: Error message!") | ||
})) | ||
.on("error", notify.onError(function (error) { | ||
return "Message to the notifier: " + error.message; | ||
})); | ||
``` | ||
## License | ||
@@ -81,0 +98,0 @@ |
@@ -6,3 +6,3 @@ /*global describe, it*/ | ||
should = require('should'), | ||
through = require('through'), | ||
through = require('through2'), | ||
gutil = require('gulp-util'), | ||
@@ -237,16 +237,17 @@ join = require('path').join, | ||
instream | ||
.pipe(through(function (file) { | ||
.pipe(through.obj(function (file, enc, cb) { | ||
numFilesBefore++; | ||
this.emit("data", file); | ||
}, function () { | ||
this.push(file); | ||
cb(); | ||
}, function (cb) { | ||
numFilesBefore.should.equal(3); | ||
this.emit("end"); | ||
cb(); | ||
})) | ||
.pipe(outstream) | ||
.pipe(through(function (file) { | ||
.pipe(through.obj(function (file, enc, cb) { | ||
numFilesAfter++; | ||
this.emit("data", file); | ||
}, function () { | ||
this.push(file); | ||
cb(); | ||
}, function (callback) { | ||
numFilesAfter.should.equal(3); | ||
this.emit("end"); | ||
done(); | ||
@@ -277,4 +278,5 @@ })); | ||
gulp.src(srcFile) | ||
.pipe(through(function (file) { | ||
.pipe(through.obj(function (file, enc, cb) { | ||
this.emit("error", new gutil.PluginError("testPlugin", testMessage)); | ||
cb(); | ||
})) | ||
@@ -281,0 +283,0 @@ .on("error", onError) |
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
17152
376
108
+ Addedthrough2@~0.4.0
+ Addedobject-keys@0.4.0(transitive)
+ Addedreadable-stream@1.0.34(transitive)
+ Addedthrough2@0.4.2(transitive)
+ Addedxtend@2.1.2(transitive)
- Removedthrough@>=2.3.4
- Removedthrough@2.3.8(transitive)