gulpjs / undertaker

Task registry that allows composition through series/parallel methods.
MIT License
200 stars 31 forks source link

Custom registry must have `get` function #83

Closed stefanstranger closed 6 years ago

stefanstranger commented 6 years ago

In my Gulp build step I get the following error.

` throw err; ^

AssertionError [ERR_ASSERTION]: Custom registry must have get function at validateRegistry (C:\Users\john\Source\Repos\Contoso\ProductTasksExtension\node_modules\undertaker\lib\helpers\validateRegistry.js:28:5) at Gulp.registry (C:\Users\john\Source\Repos\Contoso\ProductTasksExtension\node_modules\undertaker\lib\registry.js:17:3) at Object. (C:\Users\john\Source\Repos\Contoso\ProductTasksExtension\gulpfile.js:10:6) at Module._compile (module.js:660:30) at Object.Module._extensions..js (module.js:671:10) at Module.load (module.js:573:32) at tryModuleLoad (module.js:513:12) at Function.Module._load (module.js:505:3) at Module.require (module.js:604:17) at require (internal/module.js:11:18) ` How do I troubleshoot is error?

Thanks Stefan

phated commented 6 years ago

custom registries are a very advanced feature. You probably don't want to be using them.

ginnsquad commented 6 years ago

@stefanstranger I ran into this error as well. I am not sure how your folder structure is setup but here is mine:

gulpfile.js
  |- gulp/
    |- default.js
    |- tasks/
      |- styles.js
      |- scripts.js
      |- clean.js

In my gulpfile.js, I have defined the HubRegistry as instructed on https://github.com/frankwallis/gulp-hub/.

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

// Load main tasks in gulp/
var hub = new HubRegistry(["./gulp/default.js"]);

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

Then in my default.js, I have

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

// Load all other gulp tasks in tasks/
var hub = new HubRegistry(["./tasks/*.js"]);

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

The problem was how the Gulp tasks were being exposed in style.js or any other Gulp task file I was trying to load. At first I was using CommonJS like this and getting the same error as you:

exports.styles = styles;

So I changed those to Gulp tasks and it worked:

gulp.task("styles", styles);

FYI - I am using Gulp 4.0 so I had also installed the latest branch of gulp-hub so I'm not sure if that will make any difference. You can install it by running npm i --save-dev gulp-hub@frankwallis/gulp-hub#4.1.0.