Gulp: Task function must be specified at Gulp.set

问题: When I try to run gulp I get the title error. My gulpfile.js: var gulp = require('gulp'), connect = require('gulp-connect-php'), gulpPhpunit = requ...

问题:

When I try to run gulp I get the title error.

My gulpfile.js:

    var gulp = require('gulp'),
        connect = require('gulp-connect-php'),
        gulpPhpunit = require('gulp-phpunit');

    gulp.task('gulpPhpunit', function() {
      var options = {debug: false};
      gulp.src('phpunit.xml') 
    .pipe(phpunit('./vendor/bin/phpunit',options));
    });

    gulp.task("default", ["gulpPhpunit"]);

The error

    // error
    assert.js:42
      throw new errors.AssertionError({
      ^

    AssertionError [ERR_ASSERTION]: Task function must be specified
        at Gulp.set [as _setTask] (/var/www/html/wptest2/node_modules/undertaker/lib/set-task.js:10:3)
        at Gulp.task (/var/www/html/wptest2/node_modules/undertaker/lib/task.js:13:8)
        at Object.<anonymous> (/var/www/html/wptest2/gulpfile.js:26:6)
        at Module._compile (module.js:652:30)
        at Object.Module._extensions..js (module.js:663:10)
        at Module.load (module.js:565:32)
        at tryModuleLoad (module.js:505:12)
        at Function.Module._load (module.js:497:3)
        at Module.require (module.js:596:17)
        at require (internal/module.js:11:18)

"Task function must be specified", am I not pointing to gulpPhpunit correctly? The code was copied out of the docs (example 2).


回答1:

If you use gulp v4, the syntax has changed. You can downgrade your gulp version or change some parts of your code to run with the new gulp version:

var gulp = require('gulp'),
    connect = require('gulp-connect-php'),
    gulpPhpunit = require('gulp-phpunit');

gulp.task('gulpPhpunit', function (done) {
    // var options = {debug: false};
    gulp.src('phpunit.xml')
        .pipe(phpunit('./vendor/bin/phpunit', options));

    done();
});

gulp.task("default", gulp.series('gulpPhpunit'));

The changes are the done callback and the gulp.series() part.

See running tasks in series

  • 发表于 2019-03-22 18:02
  • 阅读 ( 610 )
  • 分类:sof

条评论

请先 登录 后评论
不写代码的码农
小编

篇文章

作家榜 »

  1. 小编 文章
返回顶部
部分文章转自于网络,若有侵权请联系我们删除