Gulp 4 使用 Gulp-Hub 将任务拆分到多个文件由于缺少 Get 函数而失败

2023-12-20

使用 Gulp 4 和recipe https://github.com/gulpjs/gulp/blob/4.0/docs/recipes/split-tasks-across-multiple-files.md使用 gulp-hub 将我的任务拆分为多个文件会在尝试加载任务文件时引发此错误。任务文件非常简单,只是想测试一切是否正常。

我在 Github 上的 Undertaker 上找到了这个参考资料get https://github.com/gulpjs/undertaker-registry#gettaskname--function功能,但我真的不明白他们想说什么,而且 gulp-hub 似乎应该负责提升。

还有其他人遇到过这个问题并且知道如何解决吗?

吞咽文件

'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)

你可能正在跑步[email protected] /cdn-cgi/l/email-protection这是当前发布的版本npm https://www.npmjs.com/package/gulp-hub是为 gulp 3.x 设计的。

对于 gulp 4.x 你需要安装gulp-hub来自其中之一GitHub 上的开发分支 https://github.com/frankwallis/gulp-hub/branches。目前有4.0 and registry-init.

The 4.0分支现在无法工作,因为它失败了注册表验证 https://github.com/gulpjs/undertaker/blob/d1f423d/lib/helpers/validateRegistry.js#L30 of undertaker.

The registry-init不过,分支似乎有效。你可以像这样安装它:

npm uninstall gulp-hub
npm install --save-dev frankwallis/gulp-hub#registry-init
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Gulp 4 使用 Gulp-Hub 将任务拆分到多个文件由于缺少 Get 函数而失败 的相关文章