Task loading and task registration for Gulp 3.x
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.
Install with npm:
npm install gulp-tasker
In your gulpfile.js, first expose gulp-tasker globally so gulp-tasker is also available in the scope of your sub-tasks:
globaltasker = ;
Then, to load tasks from a folder, run the
This loads the tasks recursively from the /tasks/ folder from the root of your project.
To register your sub-tasks to another task like the default task, use the
To load these tasks from your gulpfile.js, add a
tasker.getTasks(name) in the place where you would specify the task dependencies:
This gets all the default tasks from the tasker plugin and returns the task list as an array as needed for gulp.
When specifying watch tasks, add a third argument to specify the folder to watch:
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:
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
|tasker.loadTasks(options)||Load all tasks from a folder
options (Object): options object containing
options.path (String, default
options.recurse (Boolean, default
|tasker.addTask(type, task, folder)||Register a task to a different task. Optional: specify a folder to register the task as a watch task
type (String): task to register new task to
task (String|Array): task to register
folder (String|Array, optional): folder to watch for changes
|tasker.getTasks(type)||Get all tasks of a type
type (String): Task type to get from gulp-tasker. Corresponds with type specified via addTask()
Copyright (C) 2014 Iain van der Wiel Licensed under the MIT license.