由于缺少Get函数,使用Gulp-Hub跨多个文件进行Gulp 4拆分任务失败 [英] Gulp 4 Split Tasks Across Multiple Files Using Gulp-Hub Fails Due to Missing Get Function
问题描述
使用Gulp 4和 recipe 使用gulp-hub将我的任务分割成多个文件,只是尝试加载任务文件时会引发此错误.任务文件非常简单,只想测试一切正常.
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.
我在Github上的Undertaker上找到了 get 函数的参考,但我真的不明白他们在说什么,似乎gulp-hub应该在做这些事情.
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文件
'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);
帮助任务-/gulp/tasks/help.js
'use strict';
var gulp = require('gulp');
gulp.task('help', []);
引发错误
$ 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)
推荐答案
You are probably running gulp-hub@0.8.0
which is the version that is currently published to npm and is designed for gulp 3.x.
对于gulp 4.x,您需要从GitHub上的开发分支之一中安装gulp-hub
.当前有4.0
和registry-init
.
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
.
4.0
分支现在无法正常工作,因为它失败了 undertaker
的注册表验证.
The 4.0
branch doesn't work right now because it fails the registry validation of undertaker
.
但是registry-init
分支似乎可以正常工作.您可以这样安装它:
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
这篇关于由于缺少Get函数,使用Gulp-Hub跨多个文件进行Gulp 4拆分任务失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!