node package manager

gulp-group

gulp-group

Build Status Coverage Status Dependency Status devDependency Status

Develop Status Develop Coverage Status

Grouping tasks for gulp.

Installation

gulp-group on NPM

Usage

Require gulp-group and pass in gulp and optional config object.

// in your gulpfile.js 
 
//instead of 
var gulp = require('gulp');
// do 
var gulp = require('gulp-group')(require('gulp'));

Example

You can group tasks using gulp.group().

var gulp = require('gulp-group')(require('gulp'));
 
gulp.group('docs', function() {
 
  gulp.group('build', function() {
 
    gulp.group('dry-run', function() {
      gulp.task('apib', function() {});
      gulp.task('html', ['./apib'], function() {});
    });
 
    gulp.task('apib', function() {});
    gulp.task('html', ['./apib'], function() {});
  });
 
  gulp.group('watch', function() {
    gulp.task('apib', ['../build/dry-run/apib'], function() {});
    gulp.task('html', ['../build/dry-run/html'], function() {});
  });
 
});
 
gulp.task('help', function() {});
gulp.group('empty', function() {});

You can now run

$ gulp docs/build/dry-run
[16:15:24] Using gulpfile /path/to/gulpfile.js
[16:15:24] Starting 'docs/build/dry-run/apib'...
[16:15:24] Finished 'docs/build/dry-run/apib' after 114 μs
[16:15:24] Starting 'docs/build/dry-run/html'...
[16:15:24] Finished 'docs/build/dry-run/html' after 27 μs
[16:15:24] Starting 'docs/build/dry-run'...
[16:15:24] Finished 'docs/build/dry-run' after 6.96 μs

By default, tasks will be defined as if they were entries in a directory structure. However, you can change these by providing a config object.

var gulp = require('gulp-group')(require('gulp'), {separator: ':', current: '~', parent: '^'});
 
gulp.group('docs', function() {
 
  gulp.group('build', function() {
 
    gulp.group('dry-run', function() {
      gulp.task('apib', function() {});
      gulp.task('html', ['~apib'], function() {});
    });
 
    gulp.task('apib', function() {});
    gulp.task('html', ['~apib'], function() {});
  });
 
  gulp.group('watch', function() {
    gulp.task('apib', ['^build:dry-run:apib'], function() {});
    gulp.task('html', ['^build:dry-run:html'], function() {});
  });
 
});
 
gulp.task('help', function() {});
gulp.group('empty', function() {});
$ gulp docs:build:dry-run
[16:15:24] Using gulpfile /path/to/gulpfile.js
[16:15:24] Starting 'docs:build:dry-run:apib'...
[16:15:24] Finished 'docs:build:dry-run:apib' after 114 μs
[16:15:24] Starting 'docs:build:dry-run:html'...
[16:15:24] Finished 'docs:build:dry-run:html' after 27 μs
[16:15:24] Starting 'docs:build:dry-run'...
[16:15:24] Finished 'docs:build:dry-run' after 6.96 μs

License

MIT