Search code examples
gulpgulp-4

Gulp 4 Split Tasks Across Multiple Files Using Gulp-Hub Fails Due to Missing Get Function


Using Gulp 4 and the recipe for splitting my tasks into multiple files using gulp-hub throws this error just from attempting to load the task files. The task file is super simple just wanted to test everything was working.

I found this reference on Undertaker on Github for the get function, but I really don't understand what they are trying to say, and it seems like gulp-hub is supposed to be doing the lifting.

Anyone else run into this and know how to solve it?

Gulp File

'use strict';

var gulp = require('gulp');

var HubRegistry = require('gulp-hub');

// Load some files into the registry
var hub = new HubRegistry(['gulp/tasks/*.js']); // only one file help.js

// Tell gulp to use the tasks just loaded
gulp.registry(hub);

Help Task - /gulp/tasks/help.js

'use strict';

var gulp = require('gulp');

gulp.task('help', []);

Error Thrown

$ gulp help
[01:36:37] Loading gulp\tasks\help.js

D:\projects\app\node_modules\undertaker\lib\helpers\validateRegistry.js:36
      throw err;
      ^
 AssertionError: Custom registry must have `get` function
    at validateRegistry (D:\projects\app\node_modules\undertaker\lib\helpers\validateRegistry.js:28:5)
    at Gulp.registry (D:\projects\app\node_modules\undertaker\lib\registry.js:17:3)
    at Object.<anonymous> (D:\projects\app\gulpfile.js:11:6)
    at Module._compile (module.js:541:32)
    at Object.Module._extensions..js (module.js:550:10)
    at Module.load (module.js:458:32)
    at tryModuleLoad (module.js:417:12)
    at Function.Module._load (module.js:409:3)
    at Module.require (module.js:468:17)
    at require (internal/module.js:20:19)

Solution

  • You are probably running [email protected] which is the version that is currently published to npm and is designed for gulp 3.x.

    For gulp 4.x you need to install gulp-hub from one of the development branches on GitHub. Currently there's 4.0 and registry-init.

    The 4.0 branch doesn't work right now because it fails the registry validation of undertaker.

    The registry-init branch seems to work however. You can install it like this:

    npm uninstall gulp-hub
    npm install --save-dev frankwallis/gulp-hub#registry-init