Skip to content
This repository has been archived by the owner on May 23, 2020. It is now read-only.

harrisjose/gulp-run-promise

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

JavaScript Style Guide npm

gulp-run-promise

Run a gulp task programatically with promises 🍭

Update for Gulp v4.0.0+

The recommended way to run tasks programatically in Gulp is to use the series method.

const { series } = require('gulp')
const { myTask } = require('./tasks')

const done = (error) => {
  if(error) { // error }
  // success
}

series(myTask)(done)

For more info about this, refer to bach which is the module Gulp uses to run tasks.

Why ?

Cause gulp.start is undocumented and there is no easy alternative to start tasks and do something else after its done. Works with gulp 3 and will be updated when gulp 4 is released.

Usage

const gulp = require('gulp')
const runTask = require('gulp-run-promise')(gulp)

runTask('some-random-task').then(() => {
  // Do something else
}).catch((error) => {
  console.error(`Error: ${error}`);
})

Notes

This works by listening to err and stop events emitted by orchestrator which is what gulp uses under the hood to run tasks. If you just want to run your gulp tasks sequentially or just control the order of execution you should not use this and check out the excellent run-sequence instead.