gulp没有调用回调-它只是在任务结束时挂起

 吴佑霖雅旺 发布于 2022-12-13 17:48

callback 正在射击,但任务挂起 Finished 'hooks:pull' after 2.04 s

gulp.task('hooks:pull', function(callback){
  var files = [
    { remote: '~/deploy/test.example.com/hooks/post-receive', local: './bin/post-receive.test' },
    { remote: '~/deploy/staging.example.com/hooks/post-receive', local: './bin/post-receive.staging' },
    { remote: '~/deploy/example.com/hooks/post-receive', local: './bin/post-receive.production' }
  ];

  async.each(files, function(file, cb) {
    var opts = {
      host: 'example.com'
    };

    opts.file = file.remote;
    opts.path = file.local;

    scp.get(opts, function(err) {
      if (err) {
        console.error(err);
        return cb(err);
      }

      console.log('%s hook has been pulled!', file.local);
      cb();
    });
  }, function(err){
    if ( err ) {
      console.error(err);
      return callback(err);
    }

    callback();
  });
});

如何获取调用回调并退出/返回的信息?

刚跑步 gulp hooks:pull

1 个回答
  • 如果节点挂起而不是退出,则可能是任务仍在运行。

    您可以使用Gulp stop挂钩将其杀死,或者如果您不在乎(并且在您的任务中不启动任何异步清理功能),也可以退出整个流程。

    应该这样做:

    process = require("process");
    gulp.on('stop', function() { process.exit(0); }
    

    2022-12-13 17:51 回答
撰写答案
今天,你开发时遇到什么问题呢?
立即提问
热门标签
PHP1.CN | 中国最专业的PHP中文社区 | PNG素材下载 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有