1.0.2 • Published 10 years ago

gulp-promise v1.0.2

Weekly downloads
2,058
License
MIT
Repository
github
Last release
10 years ago

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().

1.0.2

10 years ago

1.0.1

10 years ago

0.0.2

10 years ago

0.0.1

10 years ago