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-tasker

v0.3.1

Published

Gulp task loader and task registration manager

Downloads

80

Readme

gulp-tasker

Task loading and task registration for Gulp 3.x

Introduction

The idea behind gulp-tasker is that you are able to create independent, small sub-tasks. These sub-tasks each have their own dependencies and target tasks. Previously you would create a gulpfile which would end up containing a couple of hundred lines of code when you have a significant number of tasks.

With gulp-tasker, each task (or bundle of related tasks for that matter) can be specified in a task folder. Each task folder would then contain .js file(s) that specify the tasks to be loaded. Also, you can register sub-tasks to 'global' tasks, such as the 'default' or 'watch' tasks.

Installation

Install with npm:

npm install gulp-tasker

Usage

In your gulpfile.js, first expose gulp-tasker globally so gulp-tasker is also available in the scope of your sub-tasks:

global.tasker = require('gulp-tasker');

Task loading

Then, to load tasks from a folder, run the tasker.loadTasks(options) command:

tasker.loadTasks({
	path: 'tasks',
	recurse: true
});

This loads the tasks recursively from the /tasks/ folder from the root of your project.

Task registration

To register your sub-tasks to another task like the default task, use the tasker.addTask(options) method:

tasker.addTask('default', 'js');
tasker.addTask('deploy', 'js');

To load these tasks from your gulpfile.js, add a tasker.getTasks(name) in the place where you would specify the task dependencies:

gulp.task('default', tasker.getTasks('default').tasks);

This gets all the default tasks from the tasker plugin and returns the task list as an array as needed for gulp.

Watch tasks

When specifying watch tasks, add a third argument to specify the folder to watch:

tasker.addTask('watch', 'js', ['assets/js');

Watch tasks are a bit different than regular tasks, as watch tasks also need a specified folder to watch. To load the watch tasks from gulp-tasker, add the tasks like this:

gulp.task('watch', function () {
	tasker.getTasks('watch').tasks.forEach(function(task) {
		gulp.watch(task.folders, task.tasks);
	});
});

Watch tasks are an object of two properties, the task name and the folder to watch. Using forEach() you can iterate over the watch task array and register each task with the gulp.watch() method.

API

method | description :----- | :---------- tasker.loadTasks(options) | Load all tasks from a folderoptions (Object): options object containing path and recurse options.options.path (String, default 'gulp-tasks'): path to load tasks fromoptions.recurse (Boolean, default true): Whether to recursively load all folders within the specified path tasker.addTask(type, task, folder) | Register a task to a different task. Optional: specify a folder to register the task as a watch tasktype (String): task to register new task totask (String|Array): task to registerfolder (String|Array, optional): folder to watch for changes tasker.getTasks(type) | Get all tasks of a typetype (String): Task type to get from gulp-tasker. Corresponds with type specified via addTask()

License

Copyright (C) 2014 Iain van der Wiel Licensed under the MIT license.