Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

gulp

gulp-4

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)
like image 532
mtpultz Avatar asked Jul 22 '16 08:07

mtpultz


3 Answers

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
like image 187
Sven Schoenung Avatar answered Sep 21 '22 21:09

Sven Schoenung


Update on 12.10.2016

I work with yeoman-fountainjs and in their package.json is the following dev-dependency definied, which works like a charm:

"gulp": "gulpjs/gulp#4ed9a4a3275559c73a396eff7e1fde3824951ebb",
"gulp-hub": "frankwallis/gulp-hub#d461b9c700df9010d0a8694e4af1fb96d9f38bf4",
like image 27
Marc Avatar answered Sep 23 '22 21:09

Marc


I ran into the same error but it was because I failed to expose the tasks correctly to Gulp.

At first I was using CommonJS like this in my help.js file and getting the same error: exports.help = help;

So I changed it to a Gulp task and it worked: gulp.task("help", help);

like image 23
GinnSquad Avatar answered Sep 23 '22 21:09

GinnSquad