GulpKitALPHA

Docs

Advanced usage of GulpKit is easy with the use of GulpKit.extend.

GulpKit.extend('customSass', function(options) {
    return new GulpKit.Task('customSass', options, function() {
        return gulp.src(options.source.path)
            .pipe(sass())
            .pipe(gulp.dest(options.output.baseDir));
    });
});

GulpKit(function(kit) {
    kit.customSass({
        source: './scss/style.scss',
        output: './css'
    });
});

Options

You can support options in your custom task and conditionally add pipes to the stream.

GulpKit.extend('customOptions', function(options) {
    var defaults = {
        foo: true,
        bar: false
    };
    // Overwrite options into default settings, specify the extension like 'css'
    options = GulpKit.Options.extend(defaults, options, extension);

    return new GulpKit.Task('customOptions', options, function() {
        return gulp.src(options.source.path)
            .pipe(options.foo ? ... : util.noop())
            .pipe(gulp.dest(options.output.path));
    });
});

GulpKit(function(kit) {
    kit.customOptions({
        source: '...'
        output: '...'
        bar: true
    });
});

Testing

We use Mocha for JS testing. Testing the gulp tasks requires that the gulp stream returns a callback so that we know when it's done (support for this should be coming in Gulp 4).

new GulpKit.Task('customTested', options, function(callback) {
    return gulp.src(...)
        .pipe(...)
        .pipe(gulpFn(done));

    function done() {
        if(typeof callback == 'function') {
            callback();
        }
    }
});