gulp.series()不运行任务 [英] gulp.series() doesn't run tasks

查看:1962
本文介绍了gulp.series()不运行任务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我找不到为什么 gulp.series()在我的回调函数中没有触发。

我试图从 gulp-prompt 的用户输入中获取一个字符串,并调用构建和部署函数使用 gulp.series()。我在 gulp.series()中的任务完全不会触发。

  gulp.task('test',function(){
const prompt = require('gulp-prompt');
return gulp.src('test.js')
。 pipe(prompt.prompt({
type:'checkbox',
name:'env',
message:'你想部署哪个环境?',
选项:['qa','prod']
},函数(res){
//console.dir(res.env);
var env = res.env;
console.log(env);
console.log('hi');
gulp.series('clean','patternlab:build','tag-version',deployWeb.bind(this ,env),function(done){
done();
});
}));
});


解决方案

调用 gulp.series 'task1','task2') does not 运行 task1 task2 。它所做的只是返回一个新的功能。只有当你调用那个函数是实际执行的任务时。



这意味着在你的情况下你需要执行以下操作:

  var runTasks = gulp.series('clean','patternlab:build',$ b $'tag-version',deployWeb.bind (this,env)); 
runTasks();

整个函数(done){done(); } 你在你的代码中的一部分没有什么意义,并且不需要 gulp.series()


I can't figure out why gulp.series() is not firing in my callback function.

I'm trying to grab a string from a user input with gulp-prompt and invoke a build and deployment function with gulp.series(). My tasks within gulp.series() don't fire at all.

gulp.task('test', function(){
  const prompt = require('gulp-prompt');
  return gulp.src('test.js')
    .pipe(prompt.prompt({
        type: 'checkbox',
        name: 'env',
        message: 'which environment do you want to deploy to?',
        choices: ['qa','prod']
    },function(res){
      //console.dir(res.env);
        var env = res.env;
        console.log(env);
        console.log('hi');
        gulp.series('clean', 'patternlab:build', 'tag-version', deployWeb.bind(this, env), function(done){
          done();
        });
    }));
});

解决方案

Calling gulp.series('task1', 'task2') does not run task1 and task2. All it does is return a new function. Only once you call that function are the tasks actually executed.

That means in your case you need to do the following:

var runTasks = gulp.series('clean', 'patternlab:build',
                           'tag-version', deployWeb.bind(this, env));
runTasks();

The whole function(done){ done(); } part that you had in your code doesn't really make much sense and isn't needed for gulp.series().

这篇关于gulp.series()不运行任务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆