gulp-promisify
v1.2.2
Published
Gulp flow control using async/await.
Downloads
96
Maintainers
Readme
gulp-promisify
Enables use of Promises or ES7 async/await keywords to control the flow of Gulp 3 tasks. If using Gulp 4, you should use the .serial()
and .parallel()
methods instead of this module.
Install
$ npm install --save-dev gulp-promisify
Example
import gulp from 'gulp';
import promisify from 'gulp-promisify';
import tape from 'gulp-tape';
import xo from 'gulp-xo';
promisify(gulp);
export function lint() {
return gulp
.src('*.js')
.pipe(xo());
}
export function test() {
return gulp
.src('test.js')
.pipe(tape());
}
export function testParallel() {
lint();
test();
}
export async function testSeries() {
await lint();
await test();
}
gulp.task('lint', lint);
gulp.task('test', test);
gulp.task('test:parallel', testParallel);
gulp.task('test:series', testSeries);
API
promisify(gulp)
Causes streams returned by .src()
, .dest()
, and .symlink()
to also be Promise objects with .then()
and .catch()
methods. The promise is resolved when the stream emits the 'end'
event. This promisification propagates to all subsequent streams via .pipe()
to ensure that you may await any following stream.
gulp.src('*.js')
.pipe(somePlugin())
.pipe(anotherPlugin())
.pipe(yetAnotherPlugin()); // <- returns a promisified stream
Contribute
Standards for this project, including tests, code coverage, and semantics are enforced with a build tool. Pull requests must include passing tests with 100% code coverage and no linting errors.
Test
$ npm test
© 2016 Shannon Moeller [email protected]
Licensed under MIT