Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/adam-lynch/gulp-stream-to-promise2
Returns a promise from a Gulp stream, plus (optionally) catches pipeline-breaking errors for Gulp v3
https://github.com/adam-lynch/gulp-stream-to-promise2
Last synced: 13 days ago
JSON representation
Returns a promise from a Gulp stream, plus (optionally) catches pipeline-breaking errors for Gulp v3
- Host: GitHub
- URL: https://github.com/adam-lynch/gulp-stream-to-promise2
- Owner: adam-lynch
- License: mit
- Created: 2017-04-27T19:52:30.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2017-04-28T11:22:01.000Z (over 7 years ago)
- Last Synced: 2025-01-05T09:33:03.280Z (15 days ago)
- Language: JavaScript
- Homepage: http://adamlynch.com
- Size: 5.86 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
# gulp-stream-to-promise2
Returns a promise from a [Gulp](http://gulpjs.com/) stream, plus (optionally) catches pipeline-breaking errors for Gulp v3.
## Installation
```shell
npm install --save gulp-stream-to-promise2
```## Usage
### Passing a stream
If passed a Gulp stream, `gulpStreamToPromise` will then return a Promise;
```javascript
/* ... */
var gulpStreamToPromise = require('gulp-stream-to-promise2');gulp.task('default', function(){
var stream = gulp.src( /* ... */ )
.pipe(examplePlugin())
.pipe(anotherExamplePlugin());return gulpStreamToPromise(stream)
.then(function(){ /* success */ })
.catch(function(err){ /* error */ });
});
```### Passing a callback function
If you choose to pass a callback, it must return a gulp stream. Your callback will get called with two arguments;
- `plumbErrors`: (Function) if used in your pipeline, any errors in following pipes won't kill your pipeline / file-watching. Uses [gulp-plumber](https://www.npmjs.com/package/gulp-plumber) under the hood.
- `stopPlumbingErrors`: (Function) if you've used `plumbErrors`, you can use this function to resume default behaves for any following pipes.Note: you don't need to call these plumbing functions if you're using Gulp v4+.
`gulpStreamToPromise` will then return a Promise;
```javascript
/* ... */
var gulpStreamToPromise = require('gulp-stream-to-promise2');gulp.task('default', function(){
return gulpStreamToPromise(function(plumbErrors, stopPlumbingErrors){
return gulp.src( /* ... */ )
.pipe(plumbErrors())
.pipe(examplePlugin()) // errors from this plugin won't kill your build
.pipe(stopPlumbingErrors())
.pipe(anotherExamplePlugin()); // errors from this plugin will kill your build
})
.then(function(){ /* success */ })
.catch(function(err){ /* error */ });
});
```