
Security News
Next.js Patches Critical Middleware Vulnerability (CVE-2025-29927)
Next.js has patched a critical vulnerability (CVE-2025-29927) that allowed attackers to bypass middleware-based authorization checks in self-hosted apps.
undertaker-registry
Advanced tools
The undertaker-registry npm package is used to manage and organize tasks in Gulp, a popular JavaScript task runner. It allows developers to register, retrieve, and manage tasks in a modular way, making it easier to maintain and scale build processes.
Registering Tasks
This feature allows you to register tasks using a custom registry. The code sample demonstrates how to create a custom registry by extending the Registry class and registering a 'default' task.
const { Registry } = require('undertaker-registry');
const { task } = require('gulp');
class MyRegistry extends Registry {
init(taker) {
taker.task('default', function(cb) {
console.log('default task');
cb();
});
}
}
task.registry(new MyRegistry());
task('default')();
Retrieving Tasks
This feature allows you to retrieve tasks that have been registered. The code sample shows how to retrieve and execute a 'build' task from a custom registry.
const { Registry } = require('undertaker-registry');
const { task } = require('gulp');
class MyRegistry extends Registry {
init(taker) {
taker.task('build', function(cb) {
console.log('build task');
cb();
});
}
}
task.registry(new MyRegistry());
const buildTask = task('build');
buildTask();
Modular Task Management
This feature allows you to manage tasks in a modular way, making it easier to maintain and scale your build processes. The code sample demonstrates how to register and execute multiple tasks ('clean' and 'build') using a custom registry.
const { Registry } = require('undertaker-registry');
const { task } = require('gulp');
class MyRegistry extends Registry {
init(taker) {
taker.task('clean', function(cb) {
console.log('clean task');
cb();
});
taker.task('build', function(cb) {
console.log('build task');
cb();
});
}
}
task.registry(new MyRegistry());
task('clean')();
task('build')();
Gulp is a toolkit for automating painful or time-consuming tasks in your development workflow. It uses code over configuration and leverages the power of Node.js streams to enable fast builds. While undertaker-registry is used for task management within Gulp, Gulp itself provides a broader range of functionalities for task automation.
Orchestrator is a module for sequencing and executing tasks and dependencies in maximum concurrency. It is similar to undertaker-registry in that it helps manage tasks, but it is more focused on task orchestration and sequencing rather than modular task registration.
Grunt is a JavaScript task runner that automates repetitive tasks like minification, compilation, unit testing, and linting. It is similar to Gulp but uses a configuration-based approach rather than code-based. While undertaker-registry is specific to Gulp, Grunt provides a different approach to task automation.
Default registry in gulp 4.
var gulp = require('gulp');
var UndertakerRegistry = require('undertaker-registry');
var registry = new UndertakerRegistry();
gulp.registry(registry);
Constructor for the default registry. Inherit from this constructor to build custom registries.
No-op method that receives the undertaker instance. Useful to set pre-defined tasks using the
undertaker.task(taskName, fn)
method. Custom registries can override this method when inheriting
from this default registry.
Returns the task with that name or undefined if no task is registered with that name. Useful for custom task storage. Custom registries can override this method when inheriting from this default registry.
Adds a task to the registry. If set
modifies a task, it should return the new task so Undertaker can
properly maintain metadata for the task. Useful for adding custom behavior to every task as it is
registered in the system. Custom registries can override this method when inheriting from this default
registry.
Returns an object listing all tasks in the registry. Necessary to override if the get
method is overridden
for custom task storage. Custom registries can override this when when inheriting from this default
registry.
Custom registries are constructor functions allowing you to pre-define/share tasks or add custom functionality to your registries.
A registry's prototype should define:
init(taker)
: receives the undertaker instance to set pre-defined tasks using the task(taskName, fn)
method.get(taskName)
: returns the task with that name
or undefined
if no task is registered with that name.set(taskName, fn)
: add task to the registry. If set
modifies a task, it should return the new task.tasks()
: returns an object listing all tasks in the registry.You should not call these functions yourself; leave that to Undertaker, so it can keep its metadata consistent.
The easiest way to create a custom registry is to inherit from undertaker-registry:
var util = require('util');
var DefaultRegistry = require('undertaker-registry');
function MyRegistry() {
DefaultRegistry.call(this);
}
util.inherits(MyRegistry, DefaultRegistry);
module.exports = MyRegistry;
To share common tasks with all your projects, you can expose an init
method on the registry
prototype and it will receive the Undertaker instance as the only argument. You can then use
undertaker.task(name, fn)
to register pre-defined tasks.
For example you might want to share a clean
task:
var fs = require('fs');
var util = require('util');
var DefaultRegistry = require('undertaker-registry');
var del = require('del');
function CommonRegistry(opts) {
DefaultRegistry.call(this);
opts = opts || {};
this.buildDir = opts.buildDir || './build';
}
util.inherits(CommonRegistry, DefaultRegistry);
CommonRegistry.prototype.init = function (takerInst) {
var buildDir = this.buildDir;
var exists = fs.existsSync(buildDir);
if (exists) {
throw new Error(
'Cannot initialize common tasks. ' + buildDir + ' directory exists.'
);
}
takerInst.task('clean', function () {
return del([buildDir]);
});
};
module.exports = CommonRegistry;
Then to use it in a project:
var Undertaker = require('undertaker');
var CommonRegistry = require('myorg-common-tasks');
var taker = new Undertaker(CommonRegistry({ buildDir: '/dist' }));
taker.task(
'build',
taker.series('clean', function build(cb) {
// do things
cb();
})
);
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:
var util = require('util');
var Undertaker = require('undertaker');
var DefaultRegistry = require('undertaker-registry');
// Some task defined somewhere else
var BuildRegistry = require('./build.js');
var ServeRegistry = require('./serve.js');
function ConfigRegistry(config) {
DefaultRegistry.call(this);
this.config = config;
}
util.inherits(ConfigRegistry, DefaultRegistry);
ConfigRegistry.prototype.set = function set(name, fn) {
// The `DefaultRegistry` uses `this._tasks` for storage.
var task = (this._tasks[name] = fn.bind(this.config));
return task;
};
var taker = new Undertaker();
taker.registry(new BuildRegistry());
taker.registry(new ServeRegistry());
// `taker.registry` will reset each task in the registry with
// `ConfigRegistry.prototype.set` which will bind them to the config object.
taker.registry(
new ConfigRegistry({
src: './src',
build: './build',
bindTo: '0.0.0.0:8888',
})
);
taker.task(
'default',
taker.series('clean', 'build', 'serve', function (cb) {
console.log('Server bind to ' + this.bindTo);
console.log('Serving' + this.build);
cb();
})
);
MIT
FAQs
Default registry in gulp 4.
The npm package undertaker-registry receives a total of 1,257,705 weekly downloads. As such, undertaker-registry popularity was classified as popular.
We found that undertaker-registry demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Next.js has patched a critical vulnerability (CVE-2025-29927) that allowed attackers to bypass middleware-based authorization checks in self-hosted apps.
Security News
A survey of 500 cybersecurity pros reveals high pay isn't enough—lack of growth and flexibility is driving attrition and risking organizational security.
Product
Socket, the leader in open source security, is now available on Google Cloud Marketplace for simplified procurement and enhanced protection against supply chain attacks.