Skip to content

parisleaf/gulp-do

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

gulp-do

Don't use this. Realized it's a stupid idea.

Directory-based, promisified task management for Gulp

Installation

npm install --save-dev gulp-do

Usage

gulp-do does two things:

  1. Loads and registers tasks automatically from a directory of files.
  2. Enables promise-based task dependency management.

By default, gulp-do loads tasks from the /gulp directory. Each file in the directory should export a function that will be passed to gulp.task. The name of the task will be taken from the name of the file If the task is asynchronous, the function should return a promise.

// gulpfile.js
var gulp = require('gulp');
var task = require('gulp-do');

task.configure(gulp);
// gulp/foo.js
module.exports = function() {
  return new Promise(function(resolve, reject) {
    console.log('foo');
    setTimeout(resolve, 0);
  });
};
// gulp/bar.js
var gulp = require('gulp');
var task = require('gulp-do');

module.exports = function() {
  task.do('foo').then(function() {
    console.log('bar');
  });
};

Then from the command line:

$ gulp bar
[18:38:20] Using gulpfile ~/Projects/foodie/gulpfile.js
[18:38:20] Starting 'bar'...
foo
[18:38:20] Finished 'bar' after 706 μs
bar

API

var task = require('gulp-do');

task.configure(gulp, [options])

Call this once in your gulpfile, passing an instance of gulp. The only valid option right now is taskDir, which defaults to ./gulp. If options is a string instead of an object, it overrides taskDir.

task.do(taskname, [taskArgs...])

Perform task. Returns a promise that resolves when task is complete.

task.get(taskname)

Returns function for task.

License

MIT

About

Directory-based, promisified task management for Gulp

Resources

Stars

Watchers

Forks

Packages

No packages published