Allows custom registries to be plugged into the task system, which can provide shared tasks or augmented functionality. Registries are registered using
In order to be accepted by gulp, custom registries must follow a specific format.
If a registry instance passed to
registry() doesn't have all four methods, an error will be thrown.
If we want to register our example registry from above, we will need to pass an instance of it to
init() method of a registry is called at the very end of the
registry() function. The gulp instance passed as the only argument (
gulpInst) can be used to pre-define tasks using
|gulpInst||object||Instance of gulp.|
get() method receives a task
name for the custom registry to resolve and return, or
undefined if no task with that name exists.
|name||string||Name of the task to be retrieved.|
set() method receives a task
fn. This is called internally by
task() to provide user-registered tasks to custom registries.
|name||string||Name of the task to be set.|
|fn||function||Task function to be set.|
Must return an object listing all tasks in the registry.
To share common tasks with all your projects, you can expose an
init method on the registry and it will receive an instance of gulp as the only argument. You can then use
gulpInst.task(name, fn) to register pre-defined tasks.
For example, you might want to share a
Then to use it in a project:
By controlling how tasks are added to the registry, you can decorate them.
For example, if you wanted all tasks to share some data, you can use a custom registry to bind them to that data. Be sure to return the altered task, as per the description of registry methods above: