https://github.com/floatdrop/gulp-plumber
Fixing Node pipes
https://github.com/floatdrop/gulp-plumber
Last synced: 12 months ago
JSON representation
Fixing Node pipes
- Host: GitHub
- URL: https://github.com/floatdrop/gulp-plumber
- Owner: floatdrop
- License: mit
- Created: 2014-01-06T11:20:04.000Z (over 12 years ago)
- Default Branch: master
- Last Pushed: 2018-11-27T16:39:27.000Z (over 7 years ago)
- Last Synced: 2025-05-06T09:46:23.006Z (about 1 year ago)
- Language: JavaScript
- Homepage:
- Size: 66.4 KB
- Stars: 807
- Watchers: 8
- Forks: 29
- Open Issues: 18
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-gulp-cn - gulp-plumber - 防止错误引起管道中断Prevent pipe breaking caused by errors. (插件 / 其他插件)
- awesome-gulp - gulp-plumber - Prevent pipe breaking caused by errors. (Plugins / Miscellaneous Plugins)
README
# :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` - it will be attached to stream `on('error')`.
* `false` - error handler will not be attached.
* `true` - 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