鉴于以下gulp任务,为什么我会收到以下错误?
错误:任务完成回调调用次数过多
function myTask(options, cb) { // cb is the gulp cb
var serverInstance = http.createServer(dispatch({ /*routes*/ }));
serverInstance.listen(options.port, function() {
cb(); // Stack trace identifies this line as throwing the error
});
}
function partial(fn) {
var args = Array.prototype.slice.call(arguments, 1);
return function() {
return fn.apply(this, args.concat(Array.prototype.slice.call(arguments)));
};
}
gulp.task('task-name', ['task-dependency'], partial(myTask, { port: 8080 }));
Run Code Online (Sandbox Code Playgroud)
编辑:
以下修改使其工作(但我的问题仍然存在):
gulp.task('task-name', ['task-dependency'], function(cb) {
partial(myTask, { port: 8080 })(cb);
});
Run Code Online (Sandbox Code Playgroud)