Socket
Socket
Sign inDemoInstall

gulp-plumber

Package Overview
Dependencies
56
Maintainers
1
Versions
29
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.1 to 1.0.2

143

index.js

@@ -8,93 +8,98 @@ 'use strict';

function removeDefaultHandler(stream, event) {
var found = false;
stream.listeners(event).forEach(function (item) {
if (item.name === 'on' + event) {
found = item;
this.removeListener(event, item);
}
}, stream);
return found;
var found = false;
stream.listeners(event).forEach(function (item) {
if (item.name === 'on' + event) {
found = item;
this.removeListener(event, item);
}
}, stream);
return found;
}
function wrapPanicOnErrorHandler(stream) {
var oldHandler = removeDefaultHandler(stream, 'error');
if (oldHandler) {
stream.on('error', function onerror2(er) {
if (EE.listenerCount(stream, 'error') === 1) {
this.removeListener('error', onerror2);
oldHandler.call(stream, er);
}
});
}
var oldHandler = removeDefaultHandler(stream, 'error');
if (oldHandler) {
stream.on('error', function onerror2(er) {
if (EE.listenerCount(stream, 'error') === 1) {
this.removeListener('error', onerror2);
oldHandler.call(stream, er);
}
});
}
}
function defaultErrorHandler(error) {
// onerror2 and this handler
if (EE.listenerCount(this, 'error') < 3) {
gutil.log(
gutil.colors.cyan('Plumber') + gutil.colors.red(' found unhandled error:\n'),
error.toString()
);
}
// onerror2 and this handler
if (EE.listenerCount(this, 'error') < 3) {
gutil.log(
gutil.colors.cyan('Plumber') + gutil.colors.red(' found unhandled error:\n'),
error.toString()
);
}
}
function plumber(opts) {
opts = opts || {};
opts = opts || {};
if (typeof opts === 'function') {
opts = { errorHandler: opts };
}
if (typeof opts === 'function') {
opts = {errorHandler: opts};
}
var through = through2.obj();
through._plumber = true;
var through = through2.obj();
through._plumber = true;
if (opts.errorHandler !== false) {
through.errorHandler = (typeof opts.errorHandler === 'function') ?
opts.errorHandler :
defaultErrorHandler;
}
if (opts.errorHandler !== false) {
through.errorHandler = (typeof opts.errorHandler === 'function') ?
opts.errorHandler :
defaultErrorHandler;
}
function patchPipe(stream) {
if (stream.pipe2) {
wrapPanicOnErrorHandler(stream);
stream._pipe = stream._pipe || stream.pipe;
stream.pipe = stream.pipe2;
stream.once('readable', patchPipe.bind(null, stream));
stream._plumbed = true;
}
}
function patchPipe(stream) {
if (stream.pipe2) {
wrapPanicOnErrorHandler(stream);
stream._pipe = stream._pipe || stream.pipe;
stream.pipe = stream.pipe2;
stream.once('readable', patchPipe.bind(null, stream));
stream._plumbed = true;
}
}
through.pipe2 = function pipe2(dest) {
through.pipe2 = function pipe2(dest) {
if (!dest) {
throw new gutil.PluginError('plumber', 'Can\'t pipe to undefined');
}
if (!dest) { throw new gutil.PluginError('plumber', 'Can\'t pipe to undefined'); }
this._pipe.apply(this, arguments);
this._pipe.apply(this, arguments);
if (dest._unplumbed) {
return dest;
}
if (dest._unplumbed) { return dest; }
removeDefaultHandler(this, 'error');
removeDefaultHandler(this, 'error');
if (dest._plumber) {
return dest;
}
if (dest._plumber) { return dest; }
dest.pipe2 = pipe2;
dest.pipe2 = pipe2;
// Patching pipe method
if (opts.inherit !== false) {
patchPipe(dest);
}
// Patching pipe method
if (opts.inherit !== false) {
patchPipe(dest);
}
// Placing custom on error handler
if (this.errorHandler) {
dest.errorHandler = this.errorHandler;
dest.on('error', this.errorHandler.bind(dest));
}
// Placing custom on error handler
if (this.errorHandler) {
dest.errorHandler = this.errorHandler;
dest.on('error', this.errorHandler.bind(dest));
}
dest._plumbed = true;
dest._plumbed = true;
return dest;
};
return dest;
};
patchPipe(through);
patchPipe(through);
return through;
return through;
}

@@ -105,5 +110,5 @@

module.exports.stop = function () {
var through = through2.obj();
through._unplumbed = true;
return through;
var through = through2.obj();
through._unplumbed = true;
return through;
};
{
"name": "gulp-plumber",
"version": "1.0.1",
"version": "1.0.2",
"description": "Prevent pipe breaking caused by errors from gulp plugins",

@@ -21,21 +21,18 @@ "keywords": [

"scripts": {
"test": "istanbul test _mocha --report html -- test/*.js --reporter spec",
"coveralls": "istanbul cover ./node_modules/mocha/bin/_mocha --report lcovonly -- -R spec && cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js && rm -rf ./coverage"
"test": "xo && mocha -R spec"
},
"dependencies": {
"gulp-util": "~3",
"through2": "~0.6"
"gulp-util": "^3",
"through2": "^2"
},
"devDependencies": {
"mocha": "~1.21.4",
"coveralls": "~2.11.1",
"mocha-lcov-reporter": "0.0.1",
"istanbul": "~0.3.0",
"should": "~4.0.4",
"event-stream": "~3.1.7",
"gulp-mocha": "~1.0.0",
"gulp-watch": "~0.6.9",
"gulp": "~3",
"gulp-grep-stream": "0.0.2",
"through": "~2.3.4"
"coveralls": "^2.11.6",
"event-stream": "^3.3.2",
"gulp": "^3.9.1",
"istanbul": "^0.4.2",
"mocha": "^2.4.5",
"mocha-lcov-reporter": "^1.0.0",
"should": "^8.2.2",
"through": "^2.3.8",
"xo": "^0.12.1"
},

@@ -46,3 +43,8 @@ "engines": {

},
"xo": {
"ignore": [
"test/**"
]
},
"license": "MIT"
}
# :monkey: gulp-plumber
[![NPM version][npm-image]][npm-url] [![Build Status][travis-image]][travis-url] [![Coveralls Status][coveralls-image]][coveralls-url] [![Dependency Status][depstat-image]][depstat-url]
[![NPM version][npm-image]][npm-url] [![Build Status][travis-image]][travis-url] [![Dependency Status][depstat-image]][depstat-url]

@@ -18,3 +18,3 @@ > Prevent pipe breaking caused by errors from [gulp](https://github.com/wearefractal/gulp) plugins

Then, add it to you `gulpfile.js`:
Then, add it to your `gulpfile.js`:

@@ -83,6 +83,3 @@ ```javascript

[coveralls-url]: https://coveralls.io/r/floatdrop/gulp-plumber
[coveralls-image]: http://img.shields.io/coveralls/floatdrop/gulp-plumber.svg?style=flat
[depstat-url]: https://david-dm.org/floatdrop/gulp-plumber
[depstat-image]: http://img.shields.io/david/floatdrop/gulp-plumber.svg?style=flat
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc