gulp-promise

1.0.2 • Public • Published

Gulp Promises

Ensure reliable callbacks of multiple streams within a task.

Installation   npm version

npm install gulp-promise

Simple Usage

var promise = require("gulp-promise");
 
// the list of project
var projectsToBuild = {
  "proj1": true,
  "proj2": true
  "proj3": true
};
 
/**
 * Build JS
 */
gulp.task('js', function (cb) {
 
  var myProm = new promise();
 
  // Build the promise list
  var promiselist = [];
  for (var proj in projectsToBuild) {
    promiselist.push(proj);
  }
  // Set up the promises
  myProm.makePromises(promiselist, function () {
    if (cb) {
      cb();
    }
  });
 
  for (var proj in projectsToBuild) {
    gulp.src(['/src/**/*.js'])
      .pipe(gulp.dest('./out'))
      .pipe(myProm.deliverGulpPromise(proj));
  }
 
});

API

The constructor can be called plain or with a success callback. Eg:

var myProm = new promise();
 
// or
myProm = new promise(function() {
  // Done!
});

You can resolve promises manually (myProm.deliverPromise()) or via gulp streams (myProm.deliverGulpPromise()).

Breaking Change

In 1.0, this was changed to be a proper class and can no longer be used statically. Also, prom.deliverPromise() for gulp pipes has been replaced by prom.deliverGulpPromise().

Readme

Keywords

Package Sidebar

Install

npm i gulp-promise

Weekly Downloads

90

Version

1.0.2

License

MIT

Last publish

Collaborators

  • alexei.white