updated sys and created publi
This commit is contained in:
+9
@@ -0,0 +1,9 @@
|
||||
temp/
|
||||
coverage
|
||||
|
||||
.editorconfig
|
||||
test
|
||||
.gitattributes
|
||||
.jshintrc
|
||||
.travis.yml
|
||||
gulpfile.js
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
Copyright 2014 Vsevolod Strukchinsky
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
"Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
+83
@@ -0,0 +1,83 @@
|
||||
# :monkey: gulp-plumber
|
||||
[![NPM version][npm-image]][npm-url] [![Build Status][travis-image]][travis-url] [![Dependency Status][depstat-image]][depstat-url]
|
||||
|
||||
> Prevent pipe breaking caused by errors from [gulp](https://github.com/wearefractal/gulp) plugins
|
||||
|
||||
This :monkey:-patch plugin is fixing [issue with Node Streams piping](https://github.com/gulpjs/gulp/issues/91). For explanations, read [this small article](https://gist.github.com/floatdrop/8269868).
|
||||
|
||||
Briefly it replaces `pipe` method and removes standard `onerror` handler on `error` event, which unpipes streams on error by default.
|
||||
|
||||
## Usage :monkey:
|
||||
|
||||
First, install `gulp-plumber` as a development dependency:
|
||||
|
||||
```shell
|
||||
npm install --save-dev gulp-plumber
|
||||
```
|
||||
|
||||
Then, add it to your `gulpfile.js`:
|
||||
|
||||
```javascript
|
||||
var plumber = require('gulp-plumber');
|
||||
var coffee = require('gulp-coffee');
|
||||
|
||||
gulp.src('./src/*.ext')
|
||||
.pipe(plumber())
|
||||
.pipe(coffee())
|
||||
.pipe(gulp.dest('./dist'));
|
||||
```
|
||||
|
||||
## API :monkey:
|
||||
|
||||
### :monkey: plumber([options])
|
||||
|
||||
Returns Stream, that fixes `pipe` methods on Streams that are next in pipeline.
|
||||
|
||||
#### options
|
||||
Type: `Object` / `Function`
|
||||
Default: `{}`
|
||||
|
||||
Sets options described below from its properties. If type is `Function` it will be set as `errorHandler`.
|
||||
|
||||
#### options.inherit
|
||||
Type: `Boolean`
|
||||
Default: `true`
|
||||
|
||||
Monkeypatch `pipe` functions in underlying streams in pipeline.
|
||||
|
||||
#### options.errorHandler
|
||||
Type: `Boolean` / `Function`
|
||||
Default: `true`
|
||||
|
||||
Handle errors in underlying streams and output them to console.
|
||||
* `function` passed - it will be attached to stream `on('error')`.
|
||||
* `false` passed - error handler will not be attached.
|
||||
* `undefined` - default error handler will be attached.
|
||||
|
||||
### plumber.stop()
|
||||
|
||||
This method will return default behaviour for pipeline after it was piped.
|
||||
|
||||
```javascript
|
||||
var plumber = require('gulp-plumber');
|
||||
|
||||
gulp.src('./src/*.scss')
|
||||
.pipe(plumber())
|
||||
.pipe(sass())
|
||||
.pipe(uglify())
|
||||
.pipe(plumber.stop())
|
||||
.pipe(gulp.dest('./dist'));
|
||||
```
|
||||
|
||||
## License :monkey:
|
||||
|
||||
[MIT License](http://en.wikipedia.org/wiki/MIT_License)
|
||||
|
||||
[npm-url]: https://npmjs.org/package/gulp-plumber
|
||||
[npm-image]: http://img.shields.io/npm/v/gulp-plumber.svg?style=flat
|
||||
|
||||
[travis-url]: https://travis-ci.org/floatdrop/gulp-plumber
|
||||
[travis-image]: http://img.shields.io/travis/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
|
||||
+111
@@ -0,0 +1,111 @@
|
||||
'use strict';
|
||||
|
||||
var through2 = require('through2');
|
||||
var EE = require('events').EventEmitter;
|
||||
var gutil = require('gulp-util');
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
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()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
function plumber(opts) {
|
||||
opts = opts || {};
|
||||
|
||||
if (typeof opts === 'function') {
|
||||
opts = {errorHandler: opts};
|
||||
}
|
||||
|
||||
var through = through2.obj();
|
||||
through._plumber = true;
|
||||
|
||||
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._plumbed = true;
|
||||
}
|
||||
}
|
||||
|
||||
through.pipe2 = function pipe2(dest) {
|
||||
if (!dest) {
|
||||
throw new gutil.PluginError('plumber', 'Can\'t pipe to undefined');
|
||||
}
|
||||
|
||||
this._pipe.apply(this, arguments);
|
||||
|
||||
if (dest._unplumbed) {
|
||||
return dest;
|
||||
}
|
||||
|
||||
removeDefaultHandler(this, 'error');
|
||||
|
||||
if (dest._plumber) {
|
||||
return dest;
|
||||
}
|
||||
|
||||
dest.pipe2 = pipe2;
|
||||
|
||||
// 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));
|
||||
}
|
||||
|
||||
dest._plumbed = true;
|
||||
|
||||
return dest;
|
||||
};
|
||||
|
||||
patchPipe(through);
|
||||
|
||||
return through;
|
||||
}
|
||||
|
||||
module.exports = plumber;
|
||||
|
||||
module.exports.stop = function () {
|
||||
var through = through2.obj();
|
||||
through._unplumbed = true;
|
||||
return through;
|
||||
};
|
||||
+110
@@ -0,0 +1,110 @@
|
||||
{
|
||||
"_args": [
|
||||
[
|
||||
{
|
||||
"raw": "gulp-plumber@^1.1.0",
|
||||
"scope": null,
|
||||
"escapedName": "gulp-plumber",
|
||||
"name": "gulp-plumber",
|
||||
"rawSpec": "^1.1.0",
|
||||
"spec": ">=1.1.0 <2.0.0",
|
||||
"type": "range"
|
||||
},
|
||||
"/mnt/Data/bach/Documents/ola/OLA#3DOC/sys"
|
||||
]
|
||||
],
|
||||
"_from": "gulp-plumber@>=1.1.0 <2.0.0",
|
||||
"_id": "gulp-plumber@1.1.0",
|
||||
"_inCache": true,
|
||||
"_location": "/gulp-plumber",
|
||||
"_nodeVersion": "4.2.4",
|
||||
"_npmOperationalInternal": {
|
||||
"host": "packages-6-west.internal.npmjs.com",
|
||||
"tmp": "tmp/gulp-plumber-1.1.0.tgz_1455017739588_0.6009564925916493"
|
||||
},
|
||||
"_npmUser": {
|
||||
"name": "floatdrop",
|
||||
"email": "floatdrop@gmail.com"
|
||||
},
|
||||
"_npmVersion": "2.14.12",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"raw": "gulp-plumber@^1.1.0",
|
||||
"scope": null,
|
||||
"escapedName": "gulp-plumber",
|
||||
"name": "gulp-plumber",
|
||||
"rawSpec": "^1.1.0",
|
||||
"spec": ">=1.1.0 <2.0.0",
|
||||
"type": "range"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"#DEV:/"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/gulp-plumber/-/gulp-plumber-1.1.0.tgz",
|
||||
"_shasum": "f12176c2d0422f60306c242fff6a01a394faba09",
|
||||
"_shrinkwrap": null,
|
||||
"_spec": "gulp-plumber@^1.1.0",
|
||||
"_where": "/mnt/Data/bach/Documents/ola/OLA#3DOC/sys",
|
||||
"author": {
|
||||
"name": "Vsevolod Strukchinsky",
|
||||
"email": "floatdrop@gmail.com",
|
||||
"url": "https://github.com/floatdrop"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/floatdrop/gulp-plumber/issues"
|
||||
},
|
||||
"dependencies": {
|
||||
"gulp-util": "^3",
|
||||
"through2": "^2"
|
||||
},
|
||||
"description": "Prevent pipe breaking caused by errors from gulp plugins",
|
||||
"devDependencies": {
|
||||
"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"
|
||||
},
|
||||
"directories": {},
|
||||
"dist": {
|
||||
"shasum": "f12176c2d0422f60306c242fff6a01a394faba09",
|
||||
"tarball": "https://registry.npmjs.org/gulp-plumber/-/gulp-plumber-1.1.0.tgz"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=0.10",
|
||||
"npm": ">=1.2.10"
|
||||
},
|
||||
"gitHead": "982ec116283b5b5907448ac932a96be31c7d872f",
|
||||
"homepage": "https://github.com/floatdrop/gulp-plumber",
|
||||
"keywords": [
|
||||
"gulpplugin"
|
||||
],
|
||||
"license": "MIT",
|
||||
"main": "./index.js",
|
||||
"maintainers": [
|
||||
{
|
||||
"name": "floatdrop",
|
||||
"email": "floatdrop@gmail.com"
|
||||
}
|
||||
],
|
||||
"name": "gulp-plumber",
|
||||
"optionalDependencies": {},
|
||||
"readme": "ERROR: No README data found!",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/floatdrop/gulp-plumber.git"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "xo && mocha -R spec"
|
||||
},
|
||||
"version": "1.1.0",
|
||||
"xo": {
|
||||
"ignore": [
|
||||
"test/**"
|
||||
]
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user