我正在努力创建一个除了调用自定义函数之外什么都不做的Gulp任务.不,我有,没有源文件,不,我没有目标文件.我只想在独立任务中调用自定义函数,因此我可以根据它来执行其他任务.
为了爱我,我检查了谷歌和SO,我找不到一个例子.我最接近的就是这个
var through = require('through2');
gulp.task(
'my-custom-task',
function ()
{
return through.obj(
function write(chunk, enc, callback) {
// here is where the custom function is called
myCustomFunction('foo', 'bar');
callback(null, chunk);
}
);
}
);
Run Code Online (Sandbox Code Playgroud)
现在这确实调用了myCustomFunction,但是当我运行任务时gulp my-custom-task,我可以看到任务开始但没有完成.
Run Code Online (Sandbox Code Playgroud)[10:55:37] Starting 'clean:tmp'... [10:55:37] Finished 'clean:tmp' after 46 ms [10:55:37] Starting 'my-custom-task'...
我应该如何正确地编写我的任务?