npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

gulp-task-master

v1.1.1

Published

Offers a way to modularize your tasks

Downloads

14

Readme

gulp-task-master

Dependency Status Dev Dependency Status Code Climate Build Status Coverage Status

Yet another module to help you modularize your gulp tasks. This may seem a bit opinionated, but it was originally built to help with my own personal projects. There are configuration options available to tailor it to your setup.

Installation

You must have gulp installed in your own project in order for this plugin to work. Install gulp if you haven't already.

npm install --save-dev gulp

Then install this package

npm install --save-dev gulp-task-master

Usage

In your project's gulpfile.js:

'use strict';

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

Then in your project's tasks directory, create your task files:

// tasks/styles.js
'use strict';

var gulp   = require('gulp');
var less   = require('gulp-less');
var concat = require('gulp-concat');
var please = require('gulp-pleeease');

module.exports = function () {
  return gulp.src('src/styles/**/*.less')
    .pipe(less())
    .pipe(concat('app.min.css'))
    .pipe(please())
    .pipe(gulp.test('dist/css'));
};

Now, you have gulp styles available in your gulp tasks. It got the 'styles' task name from the filename.

Advanced Usage

In addition to attaching your task function to your module.exports, you can also define task dependencies, a custom task name (that isn't just the filename), and even a watcher for your specific task (useful for css or js build scripts).

Below is an example of a script with all of these custom options.

// tasks/scripts.js
'use strict';

var gulp   = require('gulp');
var uglify = require('gulp-uglify');
var concat = require('gulp-concat');

module.exports = function () {
  return gulp.src('src/scripts/**/*.js')
    .pipe(concat('app.min.js'))
    .pipe(uglify())
    .pipe(gulp.dest('dist/js'));
};

module.exports.dependencies = ['coffee'];
module.exports.taskName     = 'js';
module.exports.watch        = 'src/scripts/**/*.js';

The watch task gets the same task name of the task defined plus a '.watch' (configurable). So the above example would expose the 'js' task, plus a 'js.watch' task.

You may also specify a task that just has dependencies, such as an overall build task:

// tasks/build.js
'use strict';

exports.dependencies = ['scripts', 'styles'];

Now you can run gulp build, and it will run both the scripts and the styles tasks.

Configuration

In your main gulpfile.js, you pass the options in an object hash (pojo) in the function call to gulp-task-master. Default options shown below:

'use strict';

var gulp = require('gulp-task-master')({
  dirname: 'tasks',     // The directory that tasks are located in
  pattern: '*.js',      // Pattern to use when looking for task files
  cwd: process.cwd(),   // Current working directory configuration
  watchExt: '.watch'    // Extension to append to the end of watch tasks
  gulp: require('gulp') // The gulp instance to use
});

// You can still define your own tasks or group tasks here
gulp.task('default', ['watch']);

gulp.task('build', [
  'js',
  'styles'
]);

gulp.task('watch', [
  'js.watch'
]);

If you pass in a string instead of the options hash, it will put it in the dirname option and just use the defaults as the rest of the options.

var gulp = require('gulp-task-master')('gulp-tasks/');

Contributing

PRs Welcome!

If you have a great idea on how to improve this, feel free to submit an issue or a pull requests. Although it's got 100% test coverage, I know that test coverage alone doesn't test for all use cases.