如何在全球范围内运行gulp任务

时间:2022-12-17 23:08:29

Good day people,

美好的一天,

I have a gulpfile.js with a few tasks inside it that I would like to run (from the command line) globally on my system. Is this possible? If yes, how exactly would/should I go about doing this?

我有一个gulpfile.js,里面有一些任务,我想在我的系统上全局运行(从命令行)。这可能吗?如果是的话,我到底应该怎么做?

Essentially, what I am really trying to do is to create an installable node command line tool that utilizes the tasks that I have already set up in gulp.

基本上,我真正想要做的是创建一个可安装的节点命令行工具,该工具利用我已经在gulp中设置的任务。

Looking forward to reading your responses.

期待阅读您的回复。

1 个解决方案

#1


I am pretty sure this isn't possible. This is because gulp looks for a local gulp installation and a local file. Maybe there could be an ugly hack.

我很确定这是不可能的。这是因为gulp查找本地gulp安装和本地文件。也许可能有一个丑陋的黑客。

Instead write a module yourself which maybe uses commander to get CLI functionality. If you'd want to you could then call gulp tasks from within your module.

而是自己编写一个模块,可能使用commander来获取CLI功能。如果您愿意,可以在模块中调用gulp任务。

#1


I am pretty sure this isn't possible. This is because gulp looks for a local gulp installation and a local file. Maybe there could be an ugly hack.

我很确定这是不可能的。这是因为gulp查找本地gulp安装和本地文件。也许可能有一个丑陋的黑客。

Instead write a module yourself which maybe uses commander to get CLI functionality. If you'd want to you could then call gulp tasks from within your module.

而是自己编写一个模块,可能使用commander来获取CLI功能。如果您愿意,可以在模块中调用gulp任务。