Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/393.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/41.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jsf-2/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在javascript函数中一个接一个地运行gulp函数?_Javascript_Node.js_Gulp - Fatal编程技术网

如何在javascript函数中一个接一个地运行gulp函数?

如何在javascript函数中一个接一个地运行gulp函数?,javascript,node.js,gulp,Javascript,Node.js,Gulp,以下是我现在拥有的: function make_exHtml(config) { gulp.src(config, { base: process.cwd() }) .pipe(print(function (file) { return "Found file " + file; })) .pipe(rename({ basename: 'base' })) .pipe(gulp.dest('./'));

以下是我现在拥有的:

function make_exHtml(config) {

    gulp.src(config, { base: process.cwd() })
      .pipe(print(function (file) {
          return "Found file " + file;
      }))
      .pipe(rename({ basename: 'base' }))
      .pipe(gulp.dest('./'));

    return gulp.src(config.srcTemplates)
          .pipe(print(function (file) {
              return "Added file " + file + " to template";
          }))
       .pipe(minifyHTML({ collapseWhitespace: true }))
       .pipe(templateCache({ standalone: true, root: '/app' }))
       .pipe(gulp.dest(config.destPartials))
       .pipe(gzip(gzip_options))
       .pipe(gulp.dest(config.destPartials));
}
我需要做的是确保第一口比第二口先喝。有人能告诉我怎么做吗?

你可以用。将
make_exHtml
分为两个任务

var runSequence = require('run-sequence');

gulp.task('make_exHtml', function(callback) {
  runSequence('first_task','second_task', function(){
    make_prod('xxx');
    callback();
  });
});

你能告诉我回调的意义吗。我应该为回调编写代码吗?回调只是一个函数,它将在
runSequence
完成所有任务时运行。这样,gulp就可以知道何时完成了
make_exHtml
gulp.task
函数中的参数是任务完成时需要调用的回调函数。当第一个任务和第二个任务完成时,我希望运行函数make_prod('xxx')。你能告诉我怎么做,这样我才能完全理解。非常感谢。我只接受了一个简短的问题。如果我不需要执行任何回调函数,我是否可以将其留空,或者我是否仍应在callback()中编写代码?如果不需要回调函数,则可以对其进行操作,而不是从顶部函数传递回调,以便在以其他顺序使用此任务时,它可以正常工作。